-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Correctly format extern crate
conflict resolution help
#45820
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (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. |
r? @estebank |
📌 Commit 7eaa758 has been approved by |
|
Yeah, that would make sense. This means I need to go fix rustfmt now following the steps in the contribution guidlines, correct? |
@Cldfire Yes. If this can only be fixed by updating rustfmt, you should
@bors r- |
@Cldfire I don't think this approach is correct. AFAIK, item spans generally include the terminating semi-colon, so it would be weird to make I think a better solution is that when you need the span without the |
@nrc alright, thank you for your input. I agree that that is probably a better idea. I'll close this PR and open a new one that doesn't change |
Closes #45799.
Following the advice given in the issue, I changed the parsing of
extern crate
statements to grab the span before it includes the semicolon, fixing the formatting issue. All of the UI tests, oddly enough, passed on the first run without any modification (hopefully CI tells the same story).There was one small problem that I had to work around. If
extern crate std;
was placed on the very first line of the file, the outputted suggestion formatting was malformed. I solved this by checking to make sure that thenew_binding
's span didn't equalDUMMY_SP
when determining which binding to display the suggestion for. Note that, although unrelated to this particular PR, the output for line 1 vs. any other line still differs:It's an incredibly niche circumstance, though, so I don't think it's worth opening an issue about. If anyone believes otherwise, feel free to do so.