better error message for trailing doc comment in traits (issue #56766)#57333
better error message for trailing doc comment in traits (issue #56766)#57333lcnr wants to merge 1 commit intorust-lang:masterfrom
Conversation
|
estebank
left a comment
There was a problem hiding this comment.
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. |
| 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.
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.
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 Parsercurrently 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.
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.
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