Add Suggestions for Misspelled Keywords
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.
This commit is contained in:
parent
265cd14cd4
commit
14e86eb7d9
32 changed files with 298 additions and 17 deletions
|
@ -381,6 +381,7 @@ parse_invalid_char_in_escape_msg = invalid character in {$is_hex ->
|
|||
*[false] unicode
|
||||
} escape
|
||||
|
||||
|
||||
parse_invalid_comparison_operator = invalid comparison operator `{$invalid}`
|
||||
.use_instead = `{$invalid}` is not a valid comparison operator, use `{$correct}`
|
||||
.spaceship_operator_invalid = `<=>` is not a valid comparison operator, use `std::cmp::Ordering`
|
||||
|
@ -581,6 +582,11 @@ parse_missing_trait_in_trait_impl = missing trait in a trait impl
|
|||
.suggestion_add_trait = add a trait here
|
||||
.suggestion_remove_for = for an inherent impl, drop this `for`
|
||||
|
||||
parse_misspelled_kw = {$is_incorrect_case ->
|
||||
[true] write keyword `{$similar_kw}` in lowercase
|
||||
*[false] there is a keyword `{$similar_kw}` with a similar name
|
||||
}
|
||||
|
||||
parse_modifier_lifetime = `{$modifier}` may only modify trait bounds, not lifetime bounds
|
||||
.suggestion = remove the `{$modifier}`
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue