-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(collapsible_match): exclude binding modes from struct field pattern suggestions #15608
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
babec70
to
fba062b
Compare
I could additionally mention that the user might need to push fn struct_field_pat_with_binding_mode(err: Option<Error>) {
if let Some(Error { ref token, .. }) = err {
if let Some(t) = token {
println!("token used as a ref");
}
}
} the required change will be fn struct_field_pat_with_binding_mode(err: Option<Error>) {
if let Some(Error { token: Some(ref t), .. }) = err {
println!("token used as a ref");
}
} But firstly, this is actually not required in the example provided in the original issue -- when in this situation: fn struct_field_pat_with_binding_mode(err: Option<Error>) {
if let Some(Error { ref token, .. }) = err {
if let Some(Token::Name) = token {
//~^ collapsible_match
println!("token used as a ref");
}
}
} we inline fn struct_field_pat_with_binding_mode(err: Option<Error>) {
if let Some(Error { token: Some(Token::Name), .. }) = err {
println!("token used as a ref");
}
} we not only don't need to put a I guess we could employ smarter heuristics to only add the "you'll need to push the But I ultimately decided not to bother, given that we already don't do any of that in an existing test case -- this case: rust-clippy/tests/ui/collapsible_match2.rs Lines 63 to 71 in 5ac9657
gets a message that doesn't acknowledge the ref at all:rust-clippy/tests/ui/collapsible_match2.stderr Lines 99 to 106 in 5ac9657
|
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.
Thank you!
Fixes #13287
changelog: [
collapsible_match
]: exclude binding modes from struct field pattern suggestions