-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Ignore as_deref_mut in needless_option_as_deref #8064
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
Conversation
r? @Manishearth (rust-highfive has picked a reviewer for you, use r? to override) |
Currently still catching up on stuff from travel, might not be able to provide a timely review r? @giraffate (feel free to reassign) |
Hi, hope I won't disturb you. I 'm also interested in this issue and hope to discuss it together. According to lint's comments, I think the author of lint wants to detect the situation "Option<&mut t> to Option<&mut t>", because this is not necessary, So I think this lint is valuable for detecting unnecessary use of For the example in issue #8047: fn foo(_x: Option<&mut i32>) {}
fn main() {
let mut y = 0;
let mut x = Some(&mut y);
foo(x.as_deref_mut()); // lint suggestion `x`
println!("{:?}", x); // use after move
} Is it possible to scan to check the use after move situation in #8047 or just change the suggestion level to MaybeIncorrect? |
Yeah this is more of a quick fix, it introduces a false negative in return for fixing false positives. Detecting it properly would be preferable, but I wasn't sure how to go about that easily. That could always come as a later PR, or somebody may point out something I missed |
Worth bringing up in the Clippy zulip channel and seeing what others think! https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy |
☔ The latest upstream changes (presumably #8196) made this pull request unmergeable. Please resolve the merge conflicts. |
93fa016
to
835949a
Compare
☔ The latest upstream changes (presumably #8359) made this pull request unmergeable. Please resolve the merge conflicts. |
Fixes #7846
Fixes #8047
It would be possible to only lint
as_deref_mut
where theOption
is movable + unused later, but it wasn't clear to me how to test for that. So for now at least ignore itchangelog: [
needless_option_as_deref
]: No longer lints onas_deref_mut