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.
This commit is contained in:
parent
380d53fb2c
commit
6236882127
5 changed files with 56 additions and 42 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue