diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-01-27 22:32:26 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-27 22:32:26 +0100 |
| commit | 6caa533dc7508b63c57b771b6d0195c43262c614 (patch) | |
| tree | 10e326816dfdff6cb360027d726e5e82349458d0 /compiler/rustc_parse/src/parser | |
| parent | bc26f97394e520f4bf9237c043841fab4a27ba85 (diff) | |
| parent | 6236882127eb2a9213a58bf431399727a6c3505d (diff) | |
| download | rust-6caa533dc7508b63c57b771b6d0195c43262c614.tar.gz rust-6caa533dc7508b63c57b771b6d0195c43262c614.zip | |
Rollup merge of #93325 - tmiasko:lev, r=davidtwco
Introduce a limit to Levenshtein distance computation Incorporate distance limit from `find_best_match_for_name` directly into Levenshtein distance computation. Use the string size difference as a lower bound on the distance and exit early when it exceeds the specified limit. After finding a candidate within a limit, lower the limit further to restrict the search space.
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index ade441b0e7d..06849b31256 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -423,7 +423,7 @@ impl<'a> Parser<'a> { // Maybe the user misspelled `macro_rules` (issue #91227) if self.token.is_ident() && path.segments.len() == 1 - && lev_distance("macro_rules", &path.segments[0].ident.to_string()) <= 3 + && lev_distance("macro_rules", &path.segments[0].ident.to_string(), 3).is_some() { err.span_suggestion( path.span, |
