-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #129899 - veera-sivarajan:fix-97793-pr-final, r=cheny…
…ukang Add Suggestions for Misspelled Keywords Fixes #97793 This PR detects misspelled keywords using two heuristics: 1. Lowercasing the unexpected identifier. 2. Using edit distance to find a keyword similar to the unexpected identifier. However, it does not detect each and every misspelled keyword to minimize false positives and ambiguities. More details about the implementation can be found in the comments.
- Loading branch information
Showing
59 changed files
with
702 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
trait Animal { | ||
Type Result = u8; | ||
//~^ ERROR expected one of | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
error: expected one of `!` or `::`, found `Result` | ||
--> $DIR/assoc-type.rs:2:10 | ||
| | ||
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 | ||
| | ||
LL | type Result = u8; | ||
| ~~~~ | ||
|
||
error: aborting due to 1 previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//@ edition: 2018 | ||
|
||
fn main() { | ||
async Move {} | ||
//~^ ERROR expected one of | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error: expected one of `move`, `|`, or `||`, found `Move` | ||
--> $DIR/async-move.rs:4:11 | ||
| | ||
LL | async Move {} | ||
| ^^^^ expected one of `move`, `|`, or `||` | ||
| | ||
help: write keyword `move` in lowercase | ||
| | ||
LL | async move {} | ||
| ~~~~ | ||
|
||
error: aborting due to 1 previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
cnst fn code() {} | ||
//~^ ERROR expected one of | ||
|
||
fn main() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error: expected one of `!` or `::`, found keyword `fn` | ||
--> $DIR/const-fn.rs:1:6 | ||
| | ||
LL | cnst fn code() {} | ||
| ^^ expected one of `!` or `::` | ||
| | ||
help: there is a keyword `const` with a similar name | ||
| | ||
LL | const fn code() {} | ||
| ~~~~~ | ||
|
||
error: aborting due to 1 previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fn foo<consta N: usize>(_arr: [i32; N]) {} | ||
//~^ ERROR expected one of | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error: expected one of `,`, `:`, `=`, or `>`, found `N` | ||
--> $DIR/const-generics.rs:1:15 | ||
| | ||
LL | fn foo<consta N: usize>(_arr: [i32; N]) {} | ||
| ^ expected one of `,`, `:`, `=`, or `>` | ||
| | ||
help: there is a keyword `const` with a similar name | ||
| | ||
LL | fn foo<const N: usize>(_arr: [i32; N]) {} | ||
| ~~~~~ | ||
|
||
error: aborting due to 1 previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cons A: u8 = 10; | ||
//~^ ERROR expected one of | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error: expected one of `!` or `::`, found `A` | ||
--> $DIR/const.rs:1:6 | ||
| | ||
LL | cons A: u8 = 10; | ||
| ^ expected one of `!` or `::` | ||
| | ||
help: there is a keyword `const` with a similar name | ||
| | ||
LL | const A: u8 = 10; | ||
| ~~~~~ | ||
|
||
error: aborting due to 1 previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fn main() { | ||
form i in 1..10 {} | ||
//~^ ERROR expected one of | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `i` | ||
--> $DIR/for-loop.rs:2:10 | ||
| | ||
LL | form i in 1..10 {} | ||
| ^ expected one of 8 possible tokens | ||
| | ||
help: there is a keyword `for` with a similar name | ||
| | ||
LL | for i in 1..10 {} | ||
| ~~~ | ||
|
||
error: aborting due to 1 previous error | ||
|
Oops, something went wrong.