@@ -22,7 +22,6 @@ use rustc_hir::def::{self, DefKind, MacroKinds, Namespace, NonMacroAttrKind};
2222use rustc_hir:: def_id:: { CrateNum , DefId , LocalDefId } ;
2323use rustc_middle:: middle:: stability;
2424use rustc_middle:: ty:: { RegisteredTools , TyCtxt } ;
25- use rustc_session:: lint:: BuiltinLintDiag ;
2625use rustc_session:: lint:: builtin:: {
2726 LEGACY_DERIVE_HELPERS , OUT_OF_SCOPE_MACRO_CALLS , UNKNOWN_DIAGNOSTIC_ATTRIBUTES ,
2827 UNUSED_MACRO_RULES , UNUSED_MACROS ,
@@ -685,22 +684,23 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
685684 feature_err ( & self . tcx . sess , sym:: custom_inner_attributes, path. span , msg) . emit ( ) ;
686685 }
687686
687+ const DIAG_ATTRS : & [ Symbol ] = & [ sym:: on_unimplemented, sym:: do_not_recommend] ;
688+
688689 if res == Res :: NonMacroAttr ( NonMacroAttrKind :: Tool )
689690 && let [ namespace, attribute, ..] = & * path. segments
690691 && namespace. ident . name == sym:: diagnostic
691- && ![ sym :: on_unimplemented , sym :: do_not_recommend ] . contains ( & attribute. ident . name )
692+ && !DIAG_ATTRS . contains ( & attribute. ident . name )
692693 {
693- let typo_name = find_best_match_for_name (
694- & [ sym:: on_unimplemented, sym:: do_not_recommend] ,
695- attribute. ident . name ,
696- Some ( 5 ) ,
697- ) ;
694+ let span = attribute. span ( ) ;
695+
696+ let typo = find_best_match_for_name ( DIAG_ATTRS , attribute. ident . name , Some ( 5 ) )
697+ . map ( |typo_name| errors:: UnknownDiagnosticAttributeTypoSugg { span, typo_name } ) ;
698698
699699 self . tcx . sess . psess . buffer_lint (
700700 UNKNOWN_DIAGNOSTIC_ATTRIBUTES ,
701- attribute . span ( ) ,
701+ span,
702702 node_id,
703- BuiltinLintDiag :: UnknownDiagnosticAttribute { span : attribute . span ( ) , typo_name } ,
703+ errors :: UnknownDiagnosticAttribute { typo } ,
704704 ) ;
705705 }
706706
@@ -1134,9 +1134,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11341134 OUT_OF_SCOPE_MACRO_CALLS ,
11351135 path. span ,
11361136 node_id,
1137- BuiltinLintDiag :: OutOfScopeMacroCalls {
1137+ errors :: OutOfScopeMacroCalls {
11381138 span : path. span ,
11391139 path : pprust:: path_to_string ( path) ,
1140+ // FIXME: Make this translatable.
11401141 location,
11411142 } ,
11421143 ) ;
0 commit comments