-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
better error message for trailing doc comment in traits (issue #56766) #57333
Conversation
|
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.
Did you mean to modify src/libbacktrace
in your PR? If you didn't, could you rewrite your history to not include it? Also, could you squash your commits?
Other than that it looks good to me.
164ca62
to
101e91e
Compare
@estebank Done. It seems like I somehow automatically created |
☔ The latest upstream changes (presumably #57755) made this pull request unmergeable. Please resolve the merge conflicts. |
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.
@lcnr sorry for the delay in reviewing this. You will need to rebase against master and fix the merge conflict. I have one nitpick, but otherwise, the change looks great! Thank you!
@@ -5940,6 +5940,14 @@ impl<'a> Parser<'a> { | |||
self.expect(&token::OpenDelim(token::Brace))?; | |||
let mut trait_items = vec![]; | |||
while !self.eat(&token::CloseDelim(token::Brace)) { | |||
if let token::DocComment(_) = self.token { | |||
if self.look_ahead(1, |tok| tok == &token::Token::CloseDelim(token::Brace)) { | |||
self.span_fatal_err(self.span, Error::UselessDocComment).emit(); |
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.
It'd be nice if you used struct_span_err(...).emit()
instead, and then consume the doc (as you're doing here with self.bump()
. That way the parser will "succeed" and continue to type checking in the face of this.
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.
I tried doing that, but I was unable to find a way to emit an Error
without using span_fatal_err
. All other methods of Parser
currently use a &str
instead. I might look deeper into the diagnostics system once I have the time. Might take a while though 😢
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.
I think there's struct_span_err_with_code
which will make you duplicate some of the work. That being said 1) a very small amount of duplication is potentially ok and 2) it might be very easy to unify all uses in a single method.
Also, take your time. We're here to help if you need us.
} | ||
|
||
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.
Add a let _: usize ="";
line to make sure the compiler recovers from the incorrect doc comment.
Ping from triage @lcnr: What is the status of this PR? |
I currently don't have much time and will probably want to improve the error functions of |
I don't think that I can finish this in the near future. |
closes #56766
r? @estebank