@@ -21,7 +21,6 @@ use rustc_hir::def::{self, DefKind, MacroKinds, Namespace, NonMacroAttrKind};
2121use rustc_hir:: def_id:: { CrateNum , DefId , LocalDefId } ;
2222use rustc_middle:: middle:: stability;
2323use rustc_middle:: ty:: { RegisteredTools , TyCtxt } ;
24- use rustc_session:: lint:: BuiltinLintDiag ;
2524use rustc_session:: lint:: builtin:: {
2625 LEGACY_DERIVE_HELPERS , OUT_OF_SCOPE_MACRO_CALLS , UNKNOWN_DIAGNOSTIC_ATTRIBUTES ,
2726 UNUSED_MACRO_RULES , UNUSED_MACROS ,
@@ -687,23 +686,24 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
687686 feature_err ( & self . tcx . sess , sym:: custom_inner_attributes, path. span , msg) . emit ( ) ;
688687 }
689688
689+ const DIAG_ATTRS : & [ Symbol ] =
690+ & [ sym:: on_unimplemented, sym:: do_not_recommend, sym:: on_const] ;
691+
690692 if res == Res :: NonMacroAttr ( NonMacroAttrKind :: Tool )
691693 && let [ namespace, attribute, ..] = & * path. segments
692694 && namespace. ident . name == sym:: diagnostic
693- && ![ sym:: on_unimplemented, sym:: do_not_recommend, sym:: on_const]
694- . contains ( & attribute. ident . name )
695+ && !DIAG_ATTRS . contains ( & attribute. ident . name )
695696 {
696- let typo_name = find_best_match_for_name (
697- & [ sym:: on_unimplemented, sym:: do_not_recommend, sym:: on_const] ,
698- attribute. ident . name ,
699- Some ( 5 ) ,
700- ) ;
697+ let span = attribute. span ( ) ;
698+
699+ let typo = find_best_match_for_name ( DIAG_ATTRS , attribute. ident . name , Some ( 5 ) )
700+ . map ( |typo_name| errors:: UnknownDiagnosticAttributeTypoSugg { span, typo_name } ) ;
701701
702702 self . tcx . sess . psess . buffer_lint (
703703 UNKNOWN_DIAGNOSTIC_ATTRIBUTES ,
704- attribute . span ( ) ,
704+ span,
705705 node_id,
706- BuiltinLintDiag :: UnknownDiagnosticAttribute { span : attribute . span ( ) , typo_name } ,
706+ errors :: UnknownDiagnosticAttribute { typo } ,
707707 ) ;
708708 }
709709
@@ -1130,9 +1130,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11301130 OUT_OF_SCOPE_MACRO_CALLS ,
11311131 path. span ,
11321132 node_id,
1133- BuiltinLintDiag :: OutOfScopeMacroCalls {
1133+ errors :: OutOfScopeMacroCalls {
11341134 span : path. span ,
11351135 path : pprust:: path_to_string ( path) ,
1136+ // FIXME: Make this translatable.
11361137 location,
11371138 } ,
11381139 ) ;
0 commit comments