-
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
Remove semicolon note #46258
Remove semicolon note #46258
Conversation
Added note that specifies a semicolon should be removed after a given struct
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. |
src/test/parse-fail/issue-46186.rs
Outdated
|
||
struct Struct { | ||
a: usize, | ||
} //~ ERROR expected item, found ';' |
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.
Where is the ;
? 🤔
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.
Lol, good point. Forgot to copy that over
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.
Looks good to me, a couple of nitpicks inline. r=me once they're taken care of.
src/test/parse-fail/issue-46186.rs
Outdated
}; //~ ERROR expected item, found ';' | ||
//~| NOTE consider removing the semicolon | ||
|
||
fn main() {} |
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 you turn this into a ui
test?
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.
Should I go ahead and remove this file from parse-fail then?
src/libsyntax/parse/parser.rs
Outdated
return Err(self.fatal(&format!("expected item, found `{}`", token_str))); | ||
let mut err = self.fatal(&format!("expected item, found `{}`", token_str)); | ||
if token_str == ";" { | ||
err.note("consider removing the semicolon"); |
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.
change this into a span_suggestion_short(span, msg, "".to_string())
, so that the output points at it and tools depending on the RLS can apply the change automatically.
r? @estebank Don't know why the builds are failing, I've tested them on my local branch and they seem to be working just fine. If you have any tips to help out lmk. |
The complaint from the test was
Which means that the suggestion wasn't being emitted and that there was a typo in the error message parsing. For the second, you can get away with keeping only the beginning of the text for it to match without having to worry about special characters. |
@bors r+ rollup |
📌 Commit 096e698 has been approved by |
Remove semicolon note In reference to issue rust-lang#46186 r? @estebank First time doing a pull request, if there are any suggestions on how to improve this please let me know. @jjolly
Previously (issue rust-lang#46186, pull-request rust-lang#46258), a suggestion was added to remove the semicolon after we fail to parse an item, but issue rust-lang#51603 complains that it's still insufficiently obvious why. Let's add a note. Resolves rust-lang#51603.
In reference to issue #46186
r? @estebank
First time doing a pull request, if there are any suggestions on how to improve this please let me know.
@jjolly