Recover on misspelled item keyword

This commit is contained in:
Sasha Pourcelot 2025-11-30 17:37:24 +00:00
parent f9b30df1b0
commit 9ffde14aa4
9 changed files with 111 additions and 59 deletions

View file

@ -1,6 +1,8 @@
#![feature(associated_type_defaults)]
trait Animal {
Type Result = u8;
//~^ ERROR expected one of
//~^ ERROR keyword `type` is written in the wrong case
}
fn main() {}

View file

@ -1,15 +1,10 @@
error: expected one of `!` or `::`, found `Result`
--> $DIR/assoc-type.rs:2:10
error: keyword `type` is written in the wrong case
--> $DIR/assoc-type.rs:4:5
|
LL | trait Animal {
| - while parsing this item list starting here
LL | Type Result = u8;
| ^^^^^^ expected one of `!` or `::`
LL |
LL | }
| - the item list ends here
| ^^^^
|
help: write keyword `type` in lowercase
help: write it in lowercase
|
LL - Type Result = u8;
LL + type Result = u8;

View file

@ -4,20 +4,24 @@
trait Animal {
Type Result = u8;
//~^ ERROR expected one of
//~^ ERROR keyword `type` is written in the wrong case
}
Struct Foor {
//~^ ERROR expected one of
//~^ ERROR keyword `struct` is written in the wrong case
hello: String,
}
Const A: u8 = 10;
//~^ ERROR keyword `const` is written in the wrong case
Fn code() {}
//~^ ERROR keyword `fn` is written in the wrong case
Static a: u8 = 0;
//~^ ERROR keyword `static` is written in the wrong case
usee a::b;
//~^ ERROR expected one of
fn main() {}

View file

@ -1,31 +1,74 @@
error: expected one of `!` or `::`, found `Result`
--> $DIR/recovery.rs:6:10
error: keyword `type` is written in the wrong case
--> $DIR/recovery.rs:6:5
|
LL | trait Animal {
| - while parsing this item list starting here
LL | Type Result = u8;
| ^^^^^^ expected one of `!` or `::`
LL |
LL | }
| - the item list ends here
| ^^^^
|
help: write keyword `type` in lowercase
help: write it in lowercase
|
LL - Type Result = u8;
LL + type Result = u8;
|
error: expected one of `!` or `::`, found `Foor`
--> $DIR/recovery.rs:10:8
error: keyword `struct` is written in the wrong case
--> $DIR/recovery.rs:10:1
|
LL | Struct Foor {
| ^^^^ expected one of `!` or `::`
| ^^^^^^
|
help: write keyword `struct` in lowercase (notice the capitalization)
help: write it in lowercase (notice the capitalization)
|
LL - Struct Foor {
LL + struct Foor {
|
error: aborting due to 2 previous errors
error: keyword `const` is written in the wrong case
--> $DIR/recovery.rs:15:1
|
LL | Const A: u8 = 10;
| ^^^^^
|
help: write it in lowercase (notice the capitalization)
|
LL - Const A: u8 = 10;
LL + const A: u8 = 10;
|
error: keyword `fn` is written in the wrong case
--> $DIR/recovery.rs:18:1
|
LL | Fn code() {}
| ^^
|
help: write it in lowercase (notice the capitalization)
|
LL - Fn code() {}
LL + fn code() {}
|
error: keyword `static` is written in the wrong case
--> $DIR/recovery.rs:21:1
|
LL | Static a: u8 = 0;
| ^^^^^^
|
help: write it in lowercase (notice the capitalization)
|
LL - Static a: u8 = 0;
LL + static a: u8 = 0;
|
error: expected one of `!` or `::`, found `a`
--> $DIR/recovery.rs:24:6
|
LL | usee a::b;
| ^ expected one of `!` or `::`
|
help: there is a keyword `use` with a similar name
|
LL - usee a::b;
LL + use a::b;
|
error: aborting due to 6 previous errors

View file

@ -1,4 +1,3 @@
Static a = 0;
//~^ ERROR expected one of
Static a: u32 = 0;
//~^ ERROR keyword `static` is written in the wrong case
fn main() {}

View file

@ -1,13 +1,13 @@
error: expected one of `!` or `::`, found `a`
--> $DIR/static.rs:1:8
error: keyword `static` is written in the wrong case
--> $DIR/static.rs:1:1
|
LL | Static a = 0;
| ^ expected one of `!` or `::`
LL | Static a: u32 = 0;
| ^^^^^^
|
help: write keyword `static` in lowercase (notice the capitalization)
help: write it in lowercase (notice the capitalization)
|
LL - Static a = 0;
LL + static a = 0;
LL - Static a: u32 = 0;
LL + static a: u32 = 0;
|
error: aborting due to 1 previous error

View file

@ -1,4 +1,6 @@
Struct Foor {
//~^ ERROR expected one of
//~^ ERROR keyword `struct` is written in the wrong case
hello: String,
}
fn main() {}

View file

@ -1,10 +1,10 @@
error: expected one of `!` or `::`, found `Foor`
--> $DIR/struct.rs:1:8
error: keyword `struct` is written in the wrong case
--> $DIR/struct.rs:1:1
|
LL | Struct Foor {
| ^^^^ expected one of `!` or `::`
| ^^^^^^
|
help: write keyword `struct` in lowercase (notice the capitalization)
help: write it in lowercase (notice the capitalization)
|
LL - Struct Foor {
LL + struct Foor {