@@ -29,6 +29,7 @@ use rustc_session::lint::builtin::{LEGACY_DERIVE_HELPERS, SOFT_UNSTABLE};
2929use rustc_session:: lint:: builtin:: { UNUSED_MACROS , UNUSED_MACRO_RULES } ;
3030use rustc_session:: lint:: BuiltinLintDiag ;
3131use rustc_session:: parse:: feature_err;
32+ use rustc_span:: edit_distance:: edit_distance;
3233use rustc_span:: edition:: Edition ;
3334use rustc_span:: hygiene:: { self , ExpnData , ExpnKind , LocalExpnId } ;
3435use rustc_span:: hygiene:: { AstPass , MacroKind } ;
@@ -568,15 +569,24 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
568569 }
569570
570571 if res == Res :: NonMacroAttr ( NonMacroAttrKind :: Tool )
571- && path . segments . len ( ) >= 2
572- && path . segments [ 0 ] . ident . name == sym:: diagnostic
573- && path . segments [ 1 ] . ident . name != sym:: on_unimplemented
572+ && let [ namespace , attribute , .. ] = & * path . segments
573+ && namespace . ident . name == sym:: diagnostic
574+ && attribute . ident . name != sym:: on_unimplemented
574575 {
575- self . tcx . sess . psess . buffer_lint (
576+ let distance =
577+ edit_distance ( attribute. ident . name . as_str ( ) , sym:: on_unimplemented. as_str ( ) , 5 ) ;
578+
579+ let help = if distance. is_some ( ) {
580+ BuiltinLintDiag :: MaybeTypo { span : attribute. span ( ) , name : sym:: on_unimplemented }
581+ } else {
582+ BuiltinLintDiag :: Normal
583+ } ;
584+ self . tcx . sess . psess . buffer_lint_with_diagnostic (
576585 UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES ,
577- path . segments [ 1 ] . span ( ) ,
586+ attribute . span ( ) ,
578587 node_id,
579588 "unknown diagnostic attribute" ,
589+ help,
580590 ) ;
581591 }
582592
0 commit comments