@@ -723,26 +723,44 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
723723 if res == Res :: NonMacroAttr ( NonMacroAttrKind :: Tool )
724724 && let [ namespace, attribute, ..] = & * path. segments
725725 && namespace. ident . name == sym:: diagnostic
726- && !DIAGNOSTIC_ATTRIBUTES . iter ( ) . any ( |( attr, stable ) | {
726+ && !DIAGNOSTIC_ATTRIBUTES . iter ( ) . any ( |( attr, feature ) | {
727727 attribute. ident . name == * attr
728- && stable . is_none_or ( |f| self . tcx . features ( ) . enabled ( f) )
728+ && feature . is_none_or ( |f| self . tcx . features ( ) . enabled ( f) )
729729 } )
730730 {
731+ let name = attribute. ident . name ;
731732 let span = attribute. span ( ) ;
732- let candidates = DIAGNOSTIC_ATTRIBUTES
733- . iter ( )
734- . filter_map ( |( sym, stable) | {
735- stable. is_none_or ( |f| self . tcx . features ( ) . enabled ( f) ) . then_some ( * sym)
733+
734+ let help = ' help: {
735+ if self . tcx . sess . is_nightly_build ( ) {
736+ for ( attr, feature) in DIAGNOSTIC_ATTRIBUTES {
737+ if let Some ( feature) = * feature
738+ && * attr == name
739+ {
740+ break ' help Some ( errors:: UnknownDiagnosticAttributeHelp :: UseFeature {
741+ feature,
742+ } ) ;
743+ }
744+ }
745+ }
746+
747+ let candidates = DIAGNOSTIC_ATTRIBUTES
748+ . iter ( )
749+ . filter_map ( |( attr, feature) | {
750+ feature. is_none_or ( |f| self . tcx . features ( ) . enabled ( f) ) . then_some ( * attr)
751+ } )
752+ . collect :: < Vec < _ > > ( ) ;
753+
754+ find_best_match_for_name ( & candidates, name, None ) . map ( |typo_name| {
755+ errors:: UnknownDiagnosticAttributeHelp :: Typo { span, typo_name }
736756 } )
737- . collect :: < Vec < _ > > ( ) ;
738- let typo = find_best_match_for_name ( & candidates, attribute. ident . name , None )
739- . map ( |typo_name| errors:: UnknownDiagnosticAttributeTypoSugg { span, typo_name } ) ;
757+ } ;
740758
741759 self . tcx . sess . psess . buffer_lint (
742760 UNKNOWN_DIAGNOSTIC_ATTRIBUTES ,
743761 span,
744762 node_id,
745- errors:: UnknownDiagnosticAttribute { typo } ,
763+ errors:: UnknownDiagnosticAttribute { help } ,
746764 ) ;
747765 }
748766
0 commit comments