Rollup merge of #95211 - terrarier2111:improve-parser, r=compiler-errors
Improve parser diagnostics This pr fixes https://github.com/rust-lang/rust/issues/93867 and contains a couple of diagnostics related changes to the parser. Here is a short list with some of the changes: - don't suggest the same thing that is the current token - suggest removing the current token if the following token is one of the suggestions (maybe incorrect) - tell the user to put a type or lifetime after where if there is none (as a warning) - reduce the amount of tokens suggested (via the new eat_noexpect and check_noexpect methods) If any of these changes are undesirable, i can remove them, thanks!
This commit is contained in:
commit
e3a3c00be8
22 changed files with 135 additions and 33 deletions
|
@ -260,7 +260,10 @@ impl<'a> Parser<'a> {
|
|||
if let Ok(snip) = self.span_to_snippet(pat.span) {
|
||||
err.span_label(pat.span, format!("while parsing the type for `{}`", snip));
|
||||
}
|
||||
let err = if self.check(&token::Eq) {
|
||||
// we use noexpect here because we don't actually expect Eq to be here
|
||||
// but we are still checking for it in order to be able to handle it if
|
||||
// it is there
|
||||
let err = if self.check_noexpect(&token::Eq) {
|
||||
err.emit();
|
||||
None
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue