-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uplift clippy::clone_double_ref
to rustc
#109842
Conversation
r? @wesleywiser (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Turns out that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clippy specific review.
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
3048661
to
99851d4
Compare
This comment has been minimized.
This comment has been minimized.
ebab009
to
655c9ea
Compare
☔ The latest upstream changes (presumably #110137) made this pull request unmergeable. Please resolve the merge conflicts. |
0284bb4
to
dc7f055
Compare
@rustbot ready |
@@ -31,18 +31,48 @@ declare_lint! { | |||
/// calling `clone` on a `&T` where `T` does not implement clone, actually doesn't do anything | |||
/// as references are copy. This lint detects these calls and warns the user about them. | |||
pub NOOP_METHOD_CALL, | |||
Allow, | |||
Warn, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this change and the associated changes to lib/compiler should be done in a separate PR.
Or at least the PR title and description need to be updated to reflect that this is also bumping NOOP_METHOD_CALL to warn.
But I would prefer the first option. Just uplifting clone_double_ref
seems to me very easy to r+, having to approve both is a bit harder to disentangle (esp in case we need to unland one in the future, e.g. due to lots of false positives in some yet undiscovered case -- which I have no reason to believe may happen, but stranger things have happened before).
/// reference, instead of cloning the inner type which should be what was intended. | ||
pub SUSPICIOUS_DOUBLE_REF_OP, | ||
Warn, | ||
"using `clone` on `&&T`" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lint isn't Clone
specific as implemented below? Wording, etc. should probably be adjusted?
@@ -1,6 +1,7 @@ | |||
// Check that cyclic glob imports are allowed with underscore imports | |||
|
|||
// check-pass | |||
#![allow(noop_method_call)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would actually prefer if we added the WARN
s to this UI test and others.
| | ||
LL | let non_deref_type_deref: &PlainType<u32> = non_deref_type.deref(); | ||
| ^^^^^^^^ unnecessary method call | ||
| | ||
= note: the type `&PlainType<u32>` which `deref` is being called on is the same as the type returned from `deref`, so the method call does not do anything and can be removed | ||
|
||
warning: using `.deref()` on a double reference, which copies `&PlainType<u32>` instead of dereferencing the inner type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: using `.deref()` on a double reference, which copies `&PlainType<u32>` instead of dereferencing the inner type | |
warning: using `.deref()` on a double reference, which returns `&PlainType<u32>` instead of dereferencing the inner type |
…=compiler-errors uplift `clippy::clone_double_ref` as `suspicious_double_ref_op` Split from rust-lang#109842. r? `@compiler-errors`
…=compiler-errors uplift `clippy::clone_double_ref` as `suspicious_double_ref_op` Split from rust-lang#109842. r? ``@compiler-errors``
☔ The latest upstream changes (presumably #111089) made this pull request unmergeable. Please resolve the merge conflicts. |
…=compiler-errors uplift `clippy::clone_double_ref` as `suspicious_double_ref_op` Split from rust-lang#109842. r? ``@compiler-errors``
This closes #109451, but is only part 1 for fixing #109429. The second part would be to run a selection of lints even after borrowck had errors.
rust/compiler/rustc_interface/src/passes.rs
Lines 815 to 822 in b9535c0
Note: both suggestions are pretty bad.. Why don't we just suggest dereferencing?
For Clippy:
changelog: Moves: Uplifted
clippy::clone_double_ref
into rustc