@@ -28,7 +28,7 @@ use rustc_session::lint::builtin::{
2828 UNUSED_MACRO_RULES , UNUSED_MACROS ,
2929} ;
3030use rustc_session:: parse:: feature_err;
31- use rustc_span:: edit_distance:: edit_distance ;
31+ use rustc_span:: edit_distance:: find_best_match_for_name ;
3232use rustc_span:: edition:: Edition ;
3333use rustc_span:: hygiene:: { self , AstPass , ExpnData , ExpnKind , LocalExpnId , MacroKind } ;
3434use rustc_span:: { DUMMY_SP , Ident , Span , Symbol , kw, sym} ;
@@ -652,13 +652,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
652652 if res == Res :: NonMacroAttr ( NonMacroAttrKind :: Tool )
653653 && let [ namespace, attribute, ..] = & * path. segments
654654 && namespace. ident . name == sym:: diagnostic
655- && !( attribute. ident . name == sym:: on_unimplemented
656- || attribute. ident . name == sym:: do_not_recommend)
655+ && ![ sym:: on_unimplemented, sym:: do_not_recommend] . contains ( & attribute. ident . name )
657656 {
658- let distance =
659- edit_distance ( attribute. ident . name . as_str ( ) , sym:: on_unimplemented. as_str ( ) , 5 ) ;
660-
661- let typo_name = distance. map ( |_| sym:: on_unimplemented) ;
657+ let typo_name = find_best_match_for_name (
658+ & [ sym:: on_unimplemented, sym:: do_not_recommend] ,
659+ attribute. ident . name ,
660+ Some ( 5 ) ,
661+ ) ;
662662
663663 self . tcx . sess . psess . buffer_lint (
664664 UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES ,
0 commit comments