@@ -712,25 +712,28 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
712712 feature_err ( & self . tcx . sess , sym:: custom_inner_attributes, path. span , msg) . emit ( ) ;
713713 }
714714
715- let diagnostic_attributes : & [ ( Symbol , bool ) ] = & [
716- ( sym:: on_unimplemented, true ) ,
717- ( sym:: do_not_recommend, true ) ,
718- ( sym:: on_move, true ) ,
719- ( sym:: on_const, self . tcx . features ( ) . diagnostic_on_const ( ) ) ,
720- ( sym:: on_unknown, self . tcx . features ( ) . diagnostic_on_unknown ( ) ) ,
715+ const DIAGNOSTIC_ATTRIBUTES : & [ ( Symbol , Option < Symbol > ) ] = & [
716+ ( sym:: on_unimplemented, None ) ,
717+ ( sym:: do_not_recommend, None ) ,
718+ ( sym:: on_move, None ) ,
719+ ( sym:: on_const, Some ( sym :: diagnostic_on_const) ) ,
720+ ( sym:: on_unknown, Some ( sym :: diagnostic_on_unknown) ) ,
721721 ] ;
722722
723723 if res == Res :: NonMacroAttr ( NonMacroAttrKind :: Tool )
724724 && let [ namespace, attribute, ..] = & * path. segments
725725 && namespace. ident . name == sym:: diagnostic
726- && !diagnostic_attributes
727- . iter ( )
728- . any ( |( attr, stable) | * stable && attribute. ident . name == * attr)
726+ && !DIAGNOSTIC_ATTRIBUTES . iter ( ) . any ( |( attr, stable) | {
727+ attribute. ident . name == * attr
728+ && stable. is_none_or ( |f| self . tcx . features ( ) . enabled ( f) )
729+ } )
729730 {
730731 let span = attribute. span ( ) ;
731- let candidates = diagnostic_attributes
732+ let candidates = DIAGNOSTIC_ATTRIBUTES
732733 . iter ( )
733- . filter_map ( |( sym, stable) | stable. then_some ( * sym) )
734+ . filter_map ( |( sym, stable) | {
735+ stable. is_none_or ( |f| self . tcx . features ( ) . enabled ( f) ) . then_some ( * sym)
736+ } )
734737 . collect :: < Vec < _ > > ( ) ;
735738 let typo = find_best_match_for_name ( & candidates, attribute. ident . name , Some ( 5 ) )
736739 . map ( |typo_name| errors:: UnknownDiagnosticAttributeTypoSugg { span, typo_name } ) ;
0 commit comments