Commit Graph

4667 Commits

Author SHA1 Message Date
bors
3206fb4eb1 Auto merge of #9138 - Jarcho:branches_sharing_code_2, r=giraffate
Fixes for `branches_sharing_code`

fixes #7198
fixes #7452
fixes #7555
fixes #7589

changelog: Don't suggest moving modifications to locals used in any of the condition expressions in `branches_sharing_code`
changelog: Don't suggest moving anything after a local with a significant drop in `branches_sharing_code`
2022-07-12 00:38:54 +00:00
bors
8a62b6f523 Auto merge of #9144 - alex-semenyuk:or_fun_call_span_fix, r=giraffate
Fix span for or_fun_call

Closes #9033
changelog: [`or_fun_call`]: span points to the `unwrap_or` only instead of through the entire method chain expression
2022-07-11 09:03:20 +00:00
bors
7ea4592a8b Auto merge of #9056 - Jarcho:let_unit_indirect, r=llogiq
Allow `let_unit_value` in more cases

fixes #8998

changelog: Lint `let_unit_value` less aggressively when the type is specified
2022-07-10 18:58:09 +00:00
alex-semenyuk
97cd46fa33 Fix span for or_fun_call 2022-07-10 13:11:19 +03:00
Jason Newcomb
95b78799c3 Ignore the IntoIterator::into_iter call from for loops in significant_drop_in_scrutinee 2022-07-09 08:15:13 -04:00
Jason Newcomb
55563f9ce1 Fixes for branches_sharing_code
* Don't suggest moving modifications to locals used in any of the condition expressions
* Don't suggest moving anything after a local with a significant drop
2022-07-08 20:07:55 -04:00
bors
49f73e14a9 Auto merge of #8356 - J-ZhengLi:master-issue8288, r=dswij
Simplify if let statements

fixes: #8288

---

changelog: Allowing [`qustion_mark`] lint to check `if let` expressions that immediatly return unwrapped value
2022-07-08 16:12:00 +00:00
bors
d0b8f7508c Simplify if let statements
fixes: #8288

---

changelog: Allowing [`qustion_mark`] lint to check `if let` expressions that immediatly return unwrapped value
2022-07-08 16:12:00 +00:00
Jason Newcomb
2872b7e0a4 Allow let () = .. as type inference for let_unit_value 2022-07-07 20:06:37 -04:00
Jason Newcomb
196174ddad Changes to let_unit_value
* View through locals in `let_unit_value` when determining if inference is required
* Don't remove typed let bindings for more functions
2022-07-07 20:06:36 -04:00
bors
54feac18d1 Auto merge of #8958 - Alexendoo:simple_filter_map, r=giraffate
Lint simple expressions in `manual_filter_map`, `manual_find_map`

changelog: Lint simple expressions in [`manual_filter_map`], [`manual_find_map`]

The current comparison rules out `.find(|a| a.is_some()).map(|b| b.unwrap())` because `a` being a reference can effect more complicated expressions, this adds a simple check for that case and adds the necessary derefs

There's some overlap with `option_filter_map` so `lint_filter_some_map_unwrap` now returns a `bool` to indicate it linted
2022-07-07 23:39:12 +00:00
Andrea Nall
782b484b79 Fix ICE in sugg::DerefDelegate with (named) closures
rustc comiler internals helpfully tell us how to fix the issue:

  to get the signature of a closure, use `substs.as_closure().sig()` not `fn_sig()`

Fixes ICE in #9041
2022-07-07 16:10:36 -05:00
Alex Macleod
307b8cd825 Lint simple expressions in manual_filter_map, manual_find_map 2022-07-07 11:51:42 +00:00
Marcel Hellwig
ead2c4f122 fix incorrect suggestion for maybe trait bounds 2022-07-07 12:43:16 +02:00
bors
afb34eb261 Auto merge of #9096 - Jarcho:needless_borrow_subs, r=Manishearth
Fix `needless_borrow` 9095

fixes #9095
changelog: Don't lint `needless_borrow` on method receivers when it would change which trait impl is called
2022-07-06 21:26:46 +00:00
bors
f93d418f17 Auto merge of #9099 - joshtriplett:unnecessary-lazy-eval-then-some, r=flip1995
Extend unnecessary_lazy_eval to cover `bool::then` -> `bool::then_some`

fixes #9097

changelog: Extend `unnecessary_lazy_eval` to convert `bool::then` to `bool::then_some`
2022-07-06 09:20:55 +00:00
Josh Triplett
528308b5aa Extend unnecessary_lazy_eval to cover bool::then -> bool::then_some 2022-07-06 00:48:51 -07:00
Jason Newcomb
3db0e00bdc Lint shadow_* lints in anon const blocks 2022-07-05 15:21:27 -04:00
bors
462136ac68 Auto merge of #9121 - alex-semenyuk:fix_ui_test_cast_32_bits, r=flip1995
Fix stderr for cast_size_32bit

changelog: fix stderr for cast_size_32bit
2022-07-05 08:57:12 +00:00
alexey semenyuk
2ccb05487c
Fix stderr for cast_size_32bit 2022-07-05 09:43:29 +03:00
bors
48e527e4bd Auto merge of #9117 - Jarcho:unsafe_block_closure, r=giraffate
Fix `undocumented_unsafe_blocks` in closures

fixes #9114
changelog: Fix `undocumented_unsafe_blocks` not checking for comments before the start of a closure
2022-07-05 00:20:33 +00:00
Jason Newcomb
975667945c Fix undocumented_unsafe_blocks in closures 2022-07-04 13:53:42 -04:00
Alex Macleod
fec4593082 new_without_default: ignore const generics/lifetime params on fn new 2022-07-04 14:03:11 +00:00
bors
b15f06e74f Auto merge of #9093 - Jarcho:deref_ice, r=giraffate
Fix ICE in `dereference.rs`

fixes #9089
changelog: Fix ICE when dereferencing or borrowing on explicit returns from closures
2022-07-04 00:22:17 +00:00
Serial
de646e10db Add invalid_utf8_in_unchecked 2022-07-03 15:37:30 -04:00
Jason Newcomb
988b813649 Use correct substitutions when checking if needless_borrow can apply to a method receiver 2022-07-02 15:48:46 -04:00
Jason Newcomb
3e80d3988d Fix ICE in dereference.rs 2022-07-02 00:59:58 -04:00
Alex Macleod
a5b70a4c1d Fix allow attributes in let_unit_value 2022-07-01 12:14:28 +00:00
dAxpeDDa
b7051077c9
Fix false-positive in equatable_if_let 2022-06-30 17:45:34 +02:00
Alex Macleod
6c61f7106f Uncomment test for #8734 2022-06-30 10:13:54 +00:00
Philipp Krones
f26cf11fe8
Merge remote-tracking branch 'upstream/master' into rustup 2022-06-30 10:27:25 +02:00
Jason Newcomb
adbc8499d3 Don't lint while_let_loop when drop order would change 2022-06-29 13:43:05 -04:00
bors
70f1d0d8fd Auto merge of #9043 - dswij:9037-test, r=Manishearth
`extra_unused_lifetimes` add FP test case emitting from derived attributes.

Add test to cover for #9014 which is fixed in #9037.

changelog: [`extra_unused_lifetimes`] Add FP test case emitting from derived attributes.

---

Seeing the FP from the test:

```sh
$ git revert -m 1 1d1ae10876
$ TESTNAME=extra_unused_lifetime cargo uitest
```
2022-06-29 15:09:37 +00:00
bors
90227c10f7 Auto merge of #8981 - PrestonFrom:more_details_for_significant_drop_lint, r=flip1995
Add details about how significant drop in match scrutinees can cause deadlocks

Adds more details about how a significant drop in a match scrutinee can cause a deadlock and include link to documentation.

changelog: Add more details to significant drop lint to explicitly show how temporaries in match scrutinees can cause deadlocks.
2022-06-29 13:23:21 +00:00
bors
4995b4e584 Auto merge of #9046 - xFrednet:rust-97660-expection-something-something, r=Jarcho
Fix `#[expect]` for most clippy lints

This PR fixes most `#[expect]` - lint interactions listed in rust-lang/rust#97660. [My comment in the issue](https://github.com/rust-lang/rust/issues/97660#issuecomment-1147269504) shows the current progress (Once this is merged). I plan to work on `duplicate_mod` and `multiple_inherent_impl` and leave the rest for later. I feel like stabilizing the feature is more important than fixing the last few nits, which currently also don't work with `#[allow]`.

---

changelog: none

r? `@Jarcho`

cc: rust-lang/rust#97660
2022-06-28 18:28:38 +00:00
bors
a4130e1612 Auto merge of #8355 - Jarcho:explicit_auto_deref_2, r=flip1995
Add lint `explicit_auto_deref` take 2

fixes: #234
fixes: #8367
fixes: #8380

Still things to do:

* ~~This currently only lints `&*<expr>` when it doesn't trigger `needless_borrow`.~~
* ~~This requires a borrow after a deref to trigger. So `*<expr>` changing `&&T` to `&T` won't be caught.~~
* The `deref` and `deref_mut` trait methods aren't linted.
* Neither ~~field accesses~~, nor method receivers are linted.
* ~~This probably shouldn't lint reborrowing.~~
* Full slicing to deref should probably be handled here as well. e.g. `&vec[..]` when just `&vec` would do

changelog: new lint `explicit_auto_deref`
2022-06-28 18:09:26 +00:00
Jason Newcomb
0adb3c0518 Move EqOp into Operators lint pass 2022-06-28 12:51:29 -04:00
Jason Newcomb
85c1f74fef Add explicit_auto_deref test for variadic function 2022-06-28 12:48:50 -04:00
Jason Newcomb
6d21b79be9 Fix needless_borrow suggestion when calling a trait method taking self 2022-06-28 12:48:27 -04:00
Jason Newcomb
0b4ba734cb Refactor dereference.rs
Merge `Position` and `AutoDerefStability`
2022-06-28 12:48:26 -04:00
Jason Newcomb
0204b95357 Lint explicit_auto_deref immediately after needless_borrow 2022-06-28 12:48:26 -04:00
Jason Newcomb
65bc6cb8bf Lint explicit_auto_deref without a leading borrow 2022-06-28 12:48:26 -04:00
Jason Newcomb
20ea26234a Lint field accesses in explicit_auto_deref 2022-06-28 12:48:26 -04:00
Jason Newcomb
a187d6412b Merge different parent walking loops in dereference.rs
`needless_borrow` will now walk further to find the target type.
2022-06-28 12:48:26 -04:00
Jason Newcomb
ee532c0222 Don't lint explicit_auto_deref on reborrows 2022-06-28 12:48:26 -04:00
Jason Newcomb
8a74d33570 Add explicit_auto_deref lint 2022-06-28 12:48:24 -04:00
xFrednet
d11618e6fa
Update boxed_local expect attribute location 2022-06-28 12:38:52 +02:00
bors
373bb573af Auto merge of #8639 - Jarcho:trivially_copy_pass_by_ref_5953, r=dswij
`trivially_copy_pass_by_ref` fixes

fixes #5953
fixes #2961

The fix for #5953 is overly aggressive, but the suggestion is so bad that it's worth the false negatives. Basically three things together:
* It's not obviously wrong
* It compiles
* It may actually work when tested

changelog: Don't lint `trivially_copy_pass_by_ref` when unsafe pointers are used.
changelog: Better track lifetimes when linting `trivially_copy_pass_by_ref`.
2022-06-28 07:03:57 +00:00
Preston From
3cfd1e5233 Make messages more accurate, check lint enabled 2022-06-27 22:52:22 -06:00
bors
fdd0e727e2 Auto merge of #8649 - ebobrow:imperative_find, r=flip1995
add [`manual_find`] lint for function return case

part of the implementation discussed in #7143

changelog: add [`manual_find`] lint for function return case
2022-06-27 17:15:25 +00:00