-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: collapsible_match suggests ref/derefs when needed
#14221
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
fix: collapsible_match suggests ref/derefs when needed
#14221
Conversation
281a540 to
56abdc6
Compare
This comment has been minimized.
This comment has been minimized.
|
Checking in here. It looks to me like the state is wrong now. Aren't we actually waiting on review? |
|
We are expecting both a review and a rebase. The bot settings have been changed a few days ago to let the PR in review state, so I'll reset it. @rustbot review |
bc85de9 to
0dc1cdc
Compare
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.
It looks like you ignore the fact that the reference might be mutable. The following code will suggest using .as_ref():
let mut arr = ["a", "b", "c"];
if let Some(mut last) = arr.last_mut() {
match &mut last {
&mut &mut "a" | &mut &mut "b" => {
unimplemented!()
},
_ => (),
}
}The suggestion might also be incorrect in case of raw references, where the types may not match (untested):
const NULL_PTR: *const &'static str = std::ptr::null();
if let Some(last) = arr.last() {
match &raw const *last {
NULL_PTR => unimplemented!(),
_ => (),
}
}0dc1cdc to
6116061
Compare
|
I couldn't figure out any way to handle |
6116061 to
3efde9f
Compare
|
Sorry for the delay. Thanks for making clippy better! Can you open an issue for &raw handling? I don't think we should worry about the lint ignoring them, but someone may want to implement it anyway. |
|
@vishruth-thimmaiah Rebasing and reblessing the test output should be enough to make it mergeable again. |
3efde9f to
bd7b317
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
bd7b317 to
d05fe15
Compare
d05fe15 to
9910217
Compare
Fixes: #14155
If an expression is borrowed/dereferenced, suggest using
.as_ref()or.copied()respectively in the outer conditional statement.changelog: [
collapsible_match] suggests ref/dereferencing when needed.