-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix single_match suggestions with expanded macros #3272
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 single_match suggestions with expanded macros #3272
Conversation
685bb33
to
7ee81ae
Compare
clippy_lints/src/matches.rs
Outdated
let els_str = els.map_or(String::new(), |els| format!(" else {}", expr_block(cx, els, None, ".."))); | ||
let els_str = els.map_or(String::new(), |els| { | ||
if in_macro(els.span) { | ||
" else { .. }".to_string() |
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.
Could we maybe get a better suggestion with source_callsite()
Everything else LGTM.
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 will give it a try, thanks!
7ee81ae
to
dfe08fb
Compare
Rebased onto master and added dfe08fb to include macro callsites in the suggestions. |
|
Closing in favor of #3366 |
single_match
was expanding macros in the suggested if and else expressions. This fix checks if the suggested span is inside a macro.As far as I can tell this..
Fixes #1148
Fixes #2455