-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Extend macro name suggestion span #47424
Conversation
When we suggest the replacement for a macro we include the "!" in the suggested replacement but the span only contains the name of the macro itself. Using that replacement would cause a duplicate "!" in the resulting code. Fix by extending the suggestion's span by one byte to include the "!". The error span itself still only includes the macro's name. Fixes #47418
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @estebank (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
It's legal (despite being extremely irregular style) for there to be space between the macro name and the exclamation point, so we can't simply add a byte to the span. fn main() {
println
!("rah"); // successfully prints "rah"
} |
@zackmdavis Ouch, good catch! I'll need to rethink this. |
Thank you for taking the time to fix this! What about just changing the suggestion to not include |
I have a branch for that on my home machine. I think the current message with the Thanks for the feedback! |
It should be fine, @etaoins. Tools don't care and will do the right thing, and for people it should be apparent enough that the span doesn't include the
|
…suggestion, r=estebank Don't include bang in macro replacement suggestion When we suggest the replacement for a macro we include the "!" in the suggested replacement but the span only contains the name of the macro itself. Using that replacement would cause a duplicate "!" in the resulting code. I originally tried to extend the span to be replaced by 1 byte in rust-lang#47424. However, @zackmdavis pointed out that there can be whitespace between the macro name and the bang. Instead, just remove the bang from the suggested replacement. Fixes rust-lang#47418 r? @estebank
…suggestion, r=estebank Don't include bang in macro replacement suggestion When we suggest the replacement for a macro we include the "!" in the suggested replacement but the span only contains the name of the macro itself. Using that replacement would cause a duplicate "!" in the resulting code. I originally tried to extend the span to be replaced by 1 byte in rust-lang#47424. However, @zackmdavis pointed out that there can be whitespace between the macro name and the bang. Instead, just remove the bang from the suggested replacement. Fixes rust-lang#47418 r? @estebank
…suggestion, r=estebank Don't include bang in macro replacement suggestion When we suggest the replacement for a macro we include the "!" in the suggested replacement but the span only contains the name of the macro itself. Using that replacement would cause a duplicate "!" in the resulting code. I originally tried to extend the span to be replaced by 1 byte in rust-lang#47424. However, @zackmdavis pointed out that there can be whitespace between the macro name and the bang. Instead, just remove the bang from the suggested replacement. Fixes rust-lang#47418 r? @estebank
…suggestion, r=estebank Don't include bang in macro replacement suggestion When we suggest the replacement for a macro we include the "!" in the suggested replacement but the span only contains the name of the macro itself. Using that replacement would cause a duplicate "!" in the resulting code. I originally tried to extend the span to be replaced by 1 byte in rust-lang#47424. However, @zackmdavis pointed out that there can be whitespace between the macro name and the bang. Instead, just remove the bang from the suggested replacement. Fixes rust-lang#47418 r? @estebank
When we suggest the replacement for a macro we include the "!" in the suggested replacement but the span only contains the name of the macro itself. Using that replacement would cause a duplicate "!" in the resulting code.
Fix by extending the suggestion's span by one byte to include the "!". The error span itself still only includes the macro's name.
Fixes #47418