Skip to content

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

Closed

Conversation

phansch
Copy link
Member

@phansch phansch commented Oct 6, 2018

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

@phansch phansch force-pushed the fix_single_match_suggestion_with_macro branch 3 times, most recently from 685bb33 to 7ee81ae Compare October 6, 2018 19:45
@phansch phansch added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Oct 9, 2018
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()
Copy link
Member

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.

Copy link
Member Author

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!

@phansch phansch added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Oct 16, 2018
@phansch phansch force-pushed the fix_single_match_suggestion_with_macro branch from 7ee81ae to dfe08fb Compare October 27, 2018 07:52
@phansch
Copy link
Member Author

phansch commented Oct 27, 2018

Rebased onto master and added dfe08fb to include macro callsites in the suggestions.

@phansch
Copy link
Member Author

phansch commented Oct 27, 2018

rustup-toolchain-install-master fails to compile due to rust-lang/rust#55376

@phansch phansch added S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work and removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Oct 27, 2018
@phansch
Copy link
Member Author

phansch commented Oct 27, 2018

Closing in favor of #3366

@phansch phansch closed this Oct 27, 2018
@phansch phansch deleted the fix_single_match_suggestion_with_macro branch October 27, 2018 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

single-match lint expands println! macro in suggestion Macros are being expanded when emitting suggestions
2 participants