Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Jan 4, 2019

closes #56766
r? @estebank

@rust-highfive
Copy link
Collaborator

⚠️ Warning ⚠️

  • These commits modify submodules.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 4, 2019
@lcnr lcnr changed the title for trailing doc comment (issue #56766 for trailing doc comment (issue #56766) Jan 4, 2019
@lcnr lcnr changed the title for trailing doc comment (issue #56766) better error message for trailing doc comment (issue #56766) Jan 4, 2019
@lcnr lcnr changed the title better error message for trailing doc comment (issue #56766) better error message for trailing doc comment in traits (issue #56766) Jan 4, 2019
Copy link
Contributor

@estebank estebank left a 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.

@estebank estebank added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 4, 2019
@lcnr lcnr force-pushed the doc-comment branch 2 times, most recently from 164ca62 to 101e91e Compare January 8, 2019 11:15
@lcnr
Copy link
Contributor Author

lcnr commented Jan 8, 2019

@estebank Done. It seems like I somehow automatically created src/libbacktrace as the folder is was completely new. 🤔

@bors
Copy link
Contributor

bors commented Jan 19, 2019

☔ The latest upstream changes (presumably #57755) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Contributor

@estebank estebank left a 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();
Copy link
Contributor

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.

Copy link
Contributor Author

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 Parsercurrently use a &str instead. I might look deeper into the diagnostics system once I have the time. Might take a while though 😢

Copy link
Contributor

@estebank estebank Jan 23, 2019

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() {

Copy link
Contributor

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.

@TimNN
Copy link
Contributor

TimNN commented Jan 29, 2019

Ping from triage @lcnr: What is the status of this PR?

@lcnr
Copy link
Contributor Author

lcnr commented Jan 29, 2019

I currently don't have much time and will probably want to improve the error functions of Parser before finishing this pull request. I would probably keep this open for a few more week to not forget this.

@lcnr
Copy link
Contributor Author

lcnr commented Feb 10, 2019

I don't think that I can finish this in the near future.

@lcnr lcnr closed this Feb 10, 2019
@lcnr lcnr deleted the doc-comment branch April 6, 2020 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blank document comment in trait raises error different from with that in function.
5 participants