@@ -137,6 +137,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
137137 & Attribute :: Parsed ( AttributeKind :: TypeConst ( attr_span) ) => {
138138 self . check_type_const ( hir_id, attr_span, target)
139139 }
140+ & Attribute :: Parsed ( AttributeKind :: Marker ( attr_span) ) => {
141+ self . check_marker ( hir_id, attr_span, span, target)
142+ }
140143 Attribute :: Parsed ( AttributeKind :: Confusables { first_span, .. } ) => {
141144 self . check_confusables ( * first_span, target) ;
142145 }
@@ -225,7 +228,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
225228 self . check_no_sanitize ( attr, span, target)
226229 }
227230 [ sym:: non_exhaustive, ..] => self . check_non_exhaustive ( hir_id, attr, span, target, item) ,
228- [ sym:: marker, ..] => self . check_marker ( hir_id, attr, span, target) ,
229231 [ sym:: target_feature, ..] => {
230232 self . check_target_feature ( hir_id, attr, span, target, attrs)
231233 }
@@ -792,21 +794,19 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
792794 }
793795
794796 /// Checks if the `#[marker]` attribute on an `item` is valid.
795- fn check_marker ( & self , hir_id : HirId , attr : & Attribute , span : Span , target : Target ) {
797+ fn check_marker ( & self , hir_id : HirId , attr_span : Span , span : Span , target : Target ) {
796798 match target {
797799 Target :: Trait => { }
798800 // FIXME(#80564): We permit struct fields, match arms and macro defs to have an
799801 // `#[marker]` attribute with just a lint, because we previously
800802 // erroneously allowed it and some crates used it accidentally, to be compatible
801803 // with crates depending on them, we can't throw an error here.
802804 Target :: Field | Target :: Arm | Target :: MacroDef => {
803- self . inline_attr_str_error_with_macro_def ( hir_id, attr . span ( ) , "marker" ) ;
805+ self . inline_attr_str_error_with_macro_def ( hir_id, attr_span , "marker" ) ;
804806 }
805807 _ => {
806- self . dcx ( ) . emit_err ( errors:: AttrShouldBeAppliedToTrait {
807- attr_span : attr. span ( ) ,
808- defn_span : span,
809- } ) ;
808+ self . dcx ( )
809+ . emit_err ( errors:: AttrShouldBeAppliedToTrait { attr_span, defn_span : span } ) ;
810810 }
811811 }
812812 }
0 commit comments