-
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
improve error message of inner attribute syntax #49104
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. |
537c20a
to
48be02b
Compare
src/libsyntax/parse/attr.rs
Outdated
let token_str = self.this_token_to_string(); | ||
self.bump(); | ||
let msg = "unexpected semicolon"; | ||
let help_msg = format!("consider remove this semicolon: `{}`", &token_str); |
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.
"remove" -> "removing"
Also it's better to use span_label
here instead of help
, so the "consider remove this semicolon" message appears closer to the error. Printing ": {}
" would also be unnecessary in this case.
(There are many examples of using span_label
in the parser.)
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.
thank for your advice.
I found that this situation was already covered by expect item, found {}
like error suggestion just now, so I removed the whole extra if {}
block here.
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.
Ha, indeed!
src/test/ui/issue-49040.rs
Outdated
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#![allow(unused_variables)]; |
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.
Error annotation in the test itself is also required - //~ ERROR unexpected semicolon
.
It also looks you have composed the .stderr
file manually (stderr files don't have licenses), the script src/test/ui/update-all-references.sh
can be used to generate it automatically.
CI currently fails due to these two issues.
@bors r+ rollup |
📌 Commit 9f5a356 has been approved by |
improve error message of inner attribute syntax Fixes rust-lang#49040
Fixes #49040