Commit Graph

6288 Commits

Author SHA1 Message Date
bors de80188c64 Auto merge of #7543 - DevinR528:disallowed-mod, r=Manishearth
Add module_style lint to style

changelog: Add new [`module_style`] style lint

This is a configurable (no mod file/mod file) lint that determines if `mod.rs` is used consistently or if `mod.rs` is never used (using the new mod layout).
2021-08-25 15:20:28 +00:00
bors 305177342f Auto merge of #7453 - F3real:assume_function_calls_have_side_effect, r=flip1995
Don't report function calls as unnecessary operation if used in array index

Attempts to fix: #7412

changelog: Don't report function calls used in indexing as unnecessary operation. [`unnecessary_operation`]
2021-08-25 08:31:20 +00:00
Devin Ragotzy 31738b1da3 Add module_style lint to restriction
Add tests for disallowed_mod in ui-cargo test section

Use correct algorithm to determine if mod.rs is missing

Move to two lints and remove config option

Switch lint names so they read "warn on ..."

Emit the same help info for self_named_mod_file warnings

Bail when both lints are Allow

Reword help message for both module_style lints
2021-08-24 15:53:58 -04:00
bors 87c6f32756 Auto merge of #7592 - lengyijun:redundant_allocation, r=camsteffen
redundant_allocation: fix 7487

Fixes #7487

changelog: [`redundant_allocation`] - allow `Box<Box<dyn T>>` which replaces wide pointers with thin pointers
2021-08-24 12:32:01 +00:00
lengyijun 641be558fc redundant_allocation: fix 7487 2021-08-24 13:03:48 +08:00
Cameron Steffen 2f73776525 Move branches_sharing_code to nursery 2021-08-23 13:40:04 -05:00
bors 22606e7358 Auto merge of #7539 - Labelray:master, r=camsteffen
Add new lint `negative_feature_names` and `redundant_feature_names`

Add new lint [`negative_feature_names`] to detect feature names with prefixes `no-` or `not-` and new lint [`redundant_feature_names`] to detect feature names with prefixes `use-`, `with-` or suffix `-support`
changelog: Add new lint [`negative_feature_names`] and [`redundant_feature_names`]
2021-08-23 13:56:18 +00:00
Labelray 0a021d5900 Add new lints negative_feature_names and redundant_feature_names 2021-08-23 21:05:44 +08:00
bors 1fc1aee7be Auto merge of #7565 - Jarcho:manual_split_once, r=llogiq
New lint `manual_split_once`

This is a WIP because it still needs to recognize more patterns. Currently handles:

```rust
s.splitn(2, ' ').next();
s.splitn(2, ' ').nth(0)
s.splitn(2, ' ').nth(1);
s.splitn(2, ' ').skip(0).next();
s.splitn(2, ' ').skip(1).next();
s.splitn(2, ' ').next_tuple(); // from itertools

// as well as `unwrap()` and `?` forms
```

Still to do:

```rust
let mut iter = s.splitn(2, ' ');
(iter.next().unwrap(), iter.next()?)

let mut iter = s.splitn(2, ' ');
let key = iter.next().unwrap();
let value = iter.next()?;
```

Suggestions on other patterns to check for would be useful. I've done a search on github for uses of `splitn`. Still have yet to actually look through the results.

There's also the question of whether the lint shouold trigger on all uses of `splitn` with two values, or only on recognized usages. The former could have false positives where it couldn't be replaced, but I'm not sure how common that would be.

changelog: Add lint `manual_split_once`
2021-08-17 21:15:48 +00:00
xFrednet c01aa64591 Small documentation update for the new metadata_collector 2021-08-17 14:51:56 +02:00
Jason Newcomb 3c6c7d5de9 Update docs for expl_impl_clone_on_copy. Bug was fixed in 879fa5c9721c89c27be6a9db5f51d935a51f549b1~ 2021-08-16 19:57:14 -04:00
Jason Newcomb aab3267412 Update docs for manual_split_once 2021-08-16 09:35:03 -04:00
Jason Newcomb a7f376fbd3 Add lint manual_split_once 2021-08-16 09:34:58 -04:00
Jason Newcomb 8cf6dae0ca Add for_each_local_usage. Switch LocalUsedVisitor to a function. 2021-08-16 09:34:42 -04:00
dswij a09bc1b6fe Check if let expr usage in manual_flatten
`manual_flatten` should not trigger when match expression in `if let` is
going to be used.
2021-08-16 16:25:10 +08:00
bors 3f0c97740f Auto merge of #7531 - Jarcho:manual_map_7413, r=camsteffen
Manual map 7413

fixes: #7413

This only fixes the specific problem from #7413, not the general case. The full fix requires interacting with the borrow checker to determine the lifetime of all the borrows made in the function. I'll open an issue about it later.

changelog: Don't suggest using `map` when the option is borrowed in the match, and also consumed in the arm.
changelog: Locals declared within the would-be closure will not prevent the closure from being suggested in `manual_map` and `map_entry`
2021-08-16 01:48:01 +00:00
Jason Newcomb 251dd30d77 Improve manual_map
In some cases check if a borrow made in the scrutinee expression would prevent creating the closure used by `map`
2021-08-14 19:49:54 -04:00
Jason Newcomb 4838c78ba4 Improve manual_map and map_entry
Locals which can be partially moved created within the to-be-created closure shouldn't block the use of a closure
2021-08-14 19:49:45 -04:00
David Tolnay 3c8eaa8b2c Downgrade option_if_let_else to nursery 2021-08-14 05:47:01 -07:00
dswij 91b598a8e4 Fix false positive on filter_next 2021-08-13 14:56:37 +08:00
xFrednet 206741bf57 Use avoid_breaking_exported_api for types module lints
Addressed PR reviews regarding code style
2021-08-12 22:18:42 +02:00
xFrednet 09b7745f34 Updated lint message for rc_mutex 2021-08-12 13:53:23 +02:00
flip1995 d02016d686 Merge remote-tracking branch 'upstream/master' into rustup 2021-08-12 10:58:44 +02:00
bors 62f4187ed0 Auto merge of #7546 - mgeier:patch-1, r=giraffate
similar_names: allow "iter" and "item"

changelog: [`similar_names`] no longer complains about `iter` and `item` being too similar
2021-08-12 08:16:50 +00:00
bors e62a6cad1e Auto merge of #7516 - lf-:unwrap-or-default, r=xFrednet
Add `unwrap_or_else_default` lint

---

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: Add a new [`unwrap_or_else_default`] style lint. This will catch `unwrap_or_else(Default::default)` on Result and Option and suggest `unwrap_or_default()` instead.
2021-08-12 08:02:44 +00:00
F3real 979ce29086 Correctly report inclusive range in no_effect lint 2021-08-12 01:05:41 +02:00
bors b1b38604f2 Auto merge of #7541 - LeSeulArtichaut:for-never-loop, r=camsteffen
`never_loop`: suggest using an `if let` instead of a `for` loop

changelog: suggest using an `if let` statement instead of a `for` loop that [`never_loop`]s

Fixes #7537, r? `@camsteffen.`
2021-08-11 14:49:37 +00:00
LeSeulArtichaut fc0af8e4d8 never_loop: suggest using an if let instead of a for loop 2021-08-11 16:35:33 +02:00
Jade 23d398b184 tree-wide: Fix all the rustdoc warnings 2021-08-10 14:40:26 -07:00
Jade c78cc7ac1f Add is_trait_item, refactor or_fun_call and unwrap_or_else_default 2021-08-10 14:40:26 -07:00
Jade 11ef04728c Add unwrap_or_else_default lint
This will catch `unwrap_or_else(Default::default)` on Result and Option
and suggest `unwrap_or_default()` instead.
2021-08-10 14:40:26 -07:00
bors 76c4a337d1 Auto merge of #7535 - LeSeulArtichaut:7518-self-ty-arg, r=xFrednet
Properly handle `Self` type for `trivially_copy_pass_by_ref`

changelog: properly handle `Self` type for [`trivially_copy_pass_by_ref`].

Fixes #7518
2021-08-10 10:25:26 +00:00
F3real ede977cf31 Update suggestion in case of index for unnecessary_operation lint 2021-08-10 12:08:09 +02:00
bors f998e89e43 Auto merge of #7478 - DevinR528:preemtive, r=llogiq
Fix nonstandard_macro_braces FP and docs of disallowed_types

changelog: Fix FP in [`nonstandard_macro_braces`] lint
2021-08-10 00:52:04 +00:00
bors 14d2aa1582 Auto merge of #7542 - LeSeulArtichaut:cleanups, r=flip1995
Cleanup usage of `span_to_snippet` and `LintContext::sess`

- avoid using `SourceMap::span_to_snippet` directly and use `clippy_utils::source::snippet_opt` instead
- don't use `LintContext::sess()` on `EarlyContext`s which have a `sess` field directly available, saving the import of `LintContext`

changelog: none
2021-08-09 13:48:47 +00:00
bors 0084195dee Auto merge of #7506 - HKalbasi:add-xor-swap, r=camsteffen
Add xor case to `manual swap` lint

Continue of #7153
closes #6598

changelog: Add "xor swap" case to [`manual_swap`]
2021-08-09 13:34:42 +00:00
hamidreza kalbasi 6d36d1a835 merge XOR_SWAP with MANUAL_SWAP 2021-08-09 02:15:10 +04:30
Matthias Geier bc9459f9d4 similar_names: allow "iter" and "item" 2021-08-07 18:11:49 +02:00
bors 176df7ca9a Auto merge of #7536 - LeSeulArtichaut:redundant-allocation-doc, r=giraffate
Add missing backtick in docs for `redundant_allocation`

changelog: none
2021-08-07 13:19:06 +00:00
bors 6cb30ad581 Auto merge of #7534 - LeSeulArtichaut:7517-closure-too-many-lines, r=flip1995
Don't emit `too_many_lines` for closures

changelog: don't emit the [`too_many_lines`] lint inside closures to avoir duplicated diagnostics.

Fixes #7517.
2021-08-07 13:05:53 +00:00
LeSeulArtichaut ae700b42ed Use EarlyContext::sess instead of LintContext::sess() 2021-08-07 01:59:08 +02:00
LeSeulArtichaut 64ff2b05b9 Replace span_to_snippet calls with snippet_opt from clippy_utils 2021-08-07 01:59:05 +02:00
LeSeulArtichaut 15b87088be Add missing backtick in docs for redundant_allocation 2021-08-05 19:06:35 +02:00
LeSeulArtichaut ccb5d73dec Properly handle Self type for trivially_copy_pass_by_ref 2021-08-05 18:11:08 +02:00
valentine-mario 8a4ffb881d fixed bug that had to deal with mut and non mut suggestion 2021-08-05 16:15:44 +01:00
LeSeulArtichaut 4743ec1948 Don't emit too_many_lines for closures 2021-08-05 15:38:57 +02:00
bors afe6b12b33 Auto merge of #87568 - petrochenkov:localevel, r=cjgillot
rustc: Replace `HirId`s with `LocalDefId`s in `AccessLevels` tables

and passes using those tables - primarily privacy checking, stability checking and dead code checking.

All these passes work with definitions rather than with arbitrary HIR nodes.
r? `@cjgillot`
cc `@lambinoo` (#87487)
2021-08-04 02:04:04 +00:00
Matthias Krüger 54c41c049c needless_borrow: try to make lint example a bit more illustrating 2021-08-04 00:21:25 +02:00
Devin Ragotzy bc7fac9526 fixup! Lint inside macro when owned by current crate 2021-08-03 08:19:13 -04:00
xFrednet b7d80e7d65 Updated define_Conf! to support multi-line doc comments 2021-08-02 17:56:09 +02:00