@@ -712,35 +712,33 @@ 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 ( ) ) ,
721- ] ;
722-
723715 if res == Res :: NonMacroAttr ( NonMacroAttrKind :: Tool )
724716 && let [ namespace, attribute, ..] = & * path. segments
725717 && namespace. ident . name == sym:: diagnostic
726- && !diagnostic_attributes
727- . iter ( )
728- . any ( |( attr, stable) | * stable && attribute. ident . name == * attr)
729718 {
730- let span = attribute. span ( ) ;
731- let candidates = diagnostic_attributes
732- . iter ( )
733- . filter_map ( |( sym, stable) | stable. then_some ( * sym) )
734- . collect :: < Vec < _ > > ( ) ;
735- let typo = find_best_match_for_name ( & candidates, attribute. ident . name , Some ( 5 ) )
719+ let stable_diagnostic_attributes: Vec < _ > =
720+ [ sym:: on_unimplemented, sym:: do_not_recommend, sym:: on_move]
721+ . into_iter ( )
722+ . chain ( self . tcx . features ( ) . diagnostic_on_const ( ) . then_some ( sym:: on_const) )
723+ . chain ( self . tcx . features ( ) . diagnostic_on_unknown ( ) . then_some ( sym:: on_unknown) )
724+ . collect ( ) ;
725+
726+ if !stable_diagnostic_attributes. iter ( ) . any ( |& attr| attribute. ident . name == attr) {
727+ let span = attribute. span ( ) ;
728+ let typo = find_best_match_for_name (
729+ & stable_diagnostic_attributes,
730+ attribute. ident . name ,
731+ Some ( 5 ) ,
732+ )
736733 . map ( |typo_name| errors:: UnknownDiagnosticAttributeTypoSugg { span, typo_name } ) ;
737734
738- self . tcx . sess . psess . buffer_lint (
739- UNKNOWN_DIAGNOSTIC_ATTRIBUTES ,
740- span,
741- node_id,
742- errors:: UnknownDiagnosticAttribute { typo } ,
743- ) ;
735+ self . tcx . sess . psess . buffer_lint (
736+ UNKNOWN_DIAGNOSTIC_ATTRIBUTES ,
737+ span,
738+ node_id,
739+ errors:: UnknownDiagnosticAttribute { typo } ,
740+ ) ;
741+ }
744742 }
745743
746744 Ok ( ( ext, res) )
0 commit comments