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

Give a better diagnostic for keywords with incorrect capitalization #79746

Conversation

hosseind88
Copy link
Contributor

@hosseind88 hosseind88 commented Dec 5, 2020

@rust-highfive
Copy link
Collaborator

r? @eddyb

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 5, 2020
@jyn514
Copy link
Member

jyn514 commented Dec 6, 2020

It looks like this had some regressions in other parts of the parser unfortunately:

---- [ui] ui/suggestions/issue-64252-self-type.rs stdout ----
diff of stderr:

-	error: expected one of `:`, `@`, or `|`, found `<`
-	  --> $DIR/issue-64252-self-type.rs:4:15
+	error: `"Box"` is not a keyword
+	  --> $DIR/issue-64252-self-type.rs:4:12
3	   |
4	LL | pub fn foo(Box<Self>) { }
-	   |               ^ expected one of `:`, `@`, or `|`
+	   |            ^^^ try `"box"` instead
6	   |
7	   = note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
8	help: if this is a `self` type, give it a parameter name

14	LL | pub fn foo(_: Box<Self>) { }
15	   |            ^^^^^^
16	
-	error: expected one of `:`, `@`, or `|`, found `<`
-	  --> $DIR/issue-64252-self-type.rs:10:15
+	error: `"Box"` is not a keyword
+	  --> $DIR/issue-64252-self-type.rs:10:12
19	   |
20	LL |     fn bar(Box<Self>) { }
-	   |               ^ expected one of `:`, `@`, or `|`
+	   |            ^^^ try `"box"` instead
22	   |
23	   = note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
24	help: if this is a `self` type, give it a parameter name

@jyn514 jyn514 added A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST. labels Dec 6, 2020
@jyn514
Copy link
Member

jyn514 commented Dec 6, 2020

r? @estebank

@rust-highfive rust-highfive assigned estebank and unassigned eddyb Dec 6, 2020
@estebank
Copy link
Contributor

Hi @hosseind88! Thanks for PR! This is a great idea. Could you squash your commits? Looking at the change I like the intent but I am not sure about the specific. If you run ./x.py test src/test/ui --stage 1 --bless you will see that some .stderr files will get updated as pointed out by @jyn514 and that new output is a slight regression. This would likely also happen with a parse error when a type called For or Struct goes. This approach has breath and catches a lot of cases, but if we try to go higher we could "complicate" the code by proactively checking for Idents that where previously expected... Let me think about what that would look like 🤔

@bors
Copy link
Contributor

bors commented Jan 23, 2021

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

@JohnCSimon
Copy link
Member

@hosseind88 - ping from triage. You please address the merge conflict and the comments?

@rustbot label: -S-waiting-on-review +S-waiting-on-author

@rustbot rustbot 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 Feb 7, 2021
@JohnCSimon
Copy link
Member

@hosseind88 - ping from triage. You please address the merge conflict and the comments?

@hosseind88
Copy link
Contributor Author

Hi, sorry I have been too busy since I opened this PR and I couldn't finish it, very sorry for this delay, I will try to work on it and fix issues and conflicts this week

@Dylan-DPC-zz
Copy link

Dylan-DPC-zz commented Mar 2, 2021

@hosseind75
thanks for taking the time to contribute. I have to close this due to inactivity. If you wish and you have the time you can open a new PR with these changes and we'll take it from there. Thanks

misread the previous message

@Dylan-DPC-zz Dylan-DPC-zz removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Mar 2, 2021
@Dylan-DPC-zz Dylan-DPC-zz added the S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. label Mar 2, 2021
@Dylan-DPC-zz Dylan-DPC-zz reopened this Mar 2, 2021
@Dylan-DPC-zz Dylan-DPC-zz added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. labels Mar 2, 2021
@crlf0710
Copy link
Member

@hosseind88 Ping from triage, any updates on this?

@JohnCSimon JohnCSimon added the S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. label Apr 4, 2021
@JohnCSimon
Copy link
Member

@hosseind88 Ping from triage. Unfortunately I'm going to close this as inactive.
Please feel free to reopen this when you're ready to continue working on this. Thank you!

@JohnCSimon JohnCSimon closed this Apr 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST. S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. 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.

None yet