-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Consider not warning for map_clone
with Arc::clone
#12528
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Comments
stevenengler
added
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
labels
Mar 21, 2024
@rustbot claim |
That raises the question if we should also do this for opt /* : Option<Rc<_>> */
.as_ref()
.map(Rc::clone) and suggests |
Thanks for the quick change! |
Yes, probably. I'll submit a PR to test this, after factoring the test. |
bors
added a commit
that referenced
this issue
Mar 23, 2024
`useless_asref`: do not lint `.as_ref().map(Arc::clone)` This applies to `Arc`, `Rc`, and their weak variants. Using `.clone()` would be less idiomatic. This follows the discussion in <#12528 (comment)>. changelog: [`useless_asref`]: do not lint `.as_ref().map(Arc::clone)` and similar
stevenengler
added a commit
to stevenengler/shadow
that referenced
this issue
Jun 8, 2024
This was made unnecessary by rust-lang/rust-clippy#12528.
stevenengler
added a commit
to stevenengler/shadow
that referenced
this issue
Jun 12, 2024
This was made unnecessary by rust-lang/rust-clippy#12528.
stevenengler
added a commit
to stevenengler/shadow
that referenced
this issue
Sep 9, 2024
This was made unnecessary by rust-lang/rust-clippy#12528.
stevenengler
added a commit
to stevenengler/shadow
that referenced
this issue
Sep 9, 2024
This was made unnecessary by rust-lang/rust-clippy#12528.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Summary
Similar to how some people prefer to use the fully qualified
Arc::clone(&foo)
rather thanfoo.clone()
for readability, people may also preferfoo.map(Arc::clone)
rather thanfoo.cloned()
to be more explicit that theArc
is being cloned. I think that themap_clone
lint should not trigger forfoo.map(Arc::clone)
or forfoo.map(Rc::clone)
.This is of course subjective, but it would be a subjective choice to not show a warning, which I think is nicer.
Lint Name
map_clone
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen:
No lint.
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: