From 378c4ab9ab1f75c4375425077c46cceb556fbc86 Mon Sep 17 00:00:00 2001 From: Jacob Pratt Date: Sun, 19 Feb 2023 04:03:56 +0000 Subject: Make public API, docs algorithm-agnostic --- compiler/rustc_parse/src/parser/item.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'compiler/rustc_parse/src/parser') diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index fd46a1292a8..3e3399d05c9 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -19,8 +19,8 @@ use rustc_errors::{ struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic, PResult, StashKey, }; +use rustc_span::edit_distance::edit_distance; use rustc_span::edition::Edition; -use rustc_span::lev_distance::lev_distance; use rustc_span::source_map::{self, Span}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::DUMMY_SP; @@ -459,7 +459,8 @@ 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).is_some() + && edit_distance("macro_rules", &path.segments[0].ident.to_string(), 3) + .is_some() { err.span_suggestion( path.span, -- cgit 1.4.1-3-g733a5 From 20282c1b20bb1ce196a3addc9f681cf6cf81feb9 Mon Sep 17 00:00:00 2001 From: Jacob Pratt Date: Sun, 19 Feb 2023 04:17:58 +0000 Subject: Reduce limit on `macro_rules!` diagnostic --- compiler/rustc_parse/src/parser/item.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'compiler/rustc_parse/src/parser') diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 3e3399d05c9..f164bb330f3 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -459,7 +459,7 @@ impl<'a> Parser<'a> { // Maybe the user misspelled `macro_rules` (issue #91227) if self.token.is_ident() && path.segments.len() == 1 - && edit_distance("macro_rules", &path.segments[0].ident.to_string(), 3) + && edit_distance("macro_rules", &path.segments[0].ident.to_string(), 2) .is_some() { err.span_suggestion( -- cgit 1.4.1-3-g733a5