@@ -139,6 +139,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
139
139
& Attribute :: Parsed ( AttributeKind :: TypeConst ( attr_span) ) => {
140
140
self . check_type_const ( hir_id, attr_span, target)
141
141
}
142
+ & Attribute :: Parsed ( AttributeKind :: Marker ( attr_span) ) => {
143
+ self . check_marker ( hir_id, attr_span, span, target)
144
+ }
142
145
Attribute :: Parsed ( AttributeKind :: Confusables { first_span, .. } ) => {
143
146
self . check_confusables ( * first_span, target) ;
144
147
}
@@ -240,7 +243,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
240
243
self . check_no_sanitize ( attr, span, target)
241
244
}
242
245
[ sym:: non_exhaustive, ..] => self . check_non_exhaustive ( hir_id, attr, span, target, item) ,
243
- [ sym:: marker, ..] => self . check_marker ( hir_id, attr, span, target) ,
244
246
[ sym:: thread_local, ..] => self . check_thread_local ( attr, span, target) ,
245
247
[ sym:: doc, ..] => self . check_doc_attrs (
246
248
attr,
@@ -794,21 +796,19 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
794
796
}
795
797
796
798
/// Checks if the `#[marker]` attribute on an `item` is valid.
797
- fn check_marker ( & self , hir_id : HirId , attr : & Attribute , span : Span , target : Target ) {
799
+ fn check_marker ( & self , hir_id : HirId , attr_span : Span , span : Span , target : Target ) {
798
800
match target {
799
801
Target :: Trait => { }
800
802
// FIXME(#80564): We permit struct fields, match arms and macro defs to have an
801
803
// `#[marker]` attribute with just a lint, because we previously
802
804
// erroneously allowed it and some crates used it accidentally, to be compatible
803
805
// with crates depending on them, we can't throw an error here.
804
806
Target :: Field | Target :: Arm | Target :: MacroDef => {
805
- self . inline_attr_str_error_with_macro_def ( hir_id, attr . span ( ) , "marker" ) ;
807
+ self . inline_attr_str_error_with_macro_def ( hir_id, attr_span , "marker" ) ;
806
808
}
807
809
_ => {
808
- self . dcx ( ) . emit_err ( errors:: AttrShouldBeAppliedToTrait {
809
- attr_span : attr. span ( ) ,
810
- defn_span : span,
811
- } ) ;
810
+ self . dcx ( )
811
+ . emit_err ( errors:: AttrShouldBeAppliedToTrait { attr_span, defn_span : span } ) ;
812
812
}
813
813
}
814
814
}
0 commit comments