@@ -194,6 +194,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
194
194
Attribute :: Parsed ( AttributeKind :: TrackCaller ( attr_span) ) => {
195
195
self . check_track_caller ( hir_id, * attr_span, attrs, span, target)
196
196
}
197
+ Attribute :: Parsed ( AttributeKind :: NonExhaustive ( attr_span) ) => {
198
+ self . check_non_exhaustive ( hir_id, * attr_span, span, target, item)
199
+ }
197
200
Attribute :: Parsed (
198
201
AttributeKind :: RustcLayoutScalarValidRangeStart ( _num, attr_span)
199
202
| AttributeKind :: RustcLayoutScalarValidRangeEnd ( _num, attr_span) ,
@@ -234,7 +237,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
234
237
[ sym:: no_sanitize, ..] => {
235
238
self . check_no_sanitize ( attr, span, target)
236
239
}
237
- [ sym:: non_exhaustive, ..] => self . check_non_exhaustive ( hir_id, attr, span, target, item) ,
238
240
[ sym:: marker, ..] => self . check_marker ( hir_id, attr, span, target) ,
239
241
[ sym:: thread_local, ..] => self . check_thread_local ( attr, span, target) ,
240
242
[ sym:: doc, ..] => self . check_doc_attrs (
@@ -777,7 +779,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
777
779
fn check_non_exhaustive (
778
780
& self ,
779
781
hir_id : HirId ,
780
- attr : & Attribute ,
782
+ attr_span : Span ,
781
783
span : Span ,
782
784
target : Target ,
783
785
item : Option < ItemLike < ' _ > > ,
@@ -792,7 +794,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
792
794
&& fields. iter ( ) . any ( |f| f. default . is_some ( ) )
793
795
{
794
796
self . dcx ( ) . emit_err ( errors:: NonExhaustiveWithDefaultFieldValues {
795
- attr_span : attr . span ( ) ,
797
+ attr_span,
796
798
defn_span : span,
797
799
} ) ;
798
800
}
@@ -803,13 +805,11 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
803
805
// erroneously allowed it and some crates used it accidentally, to be compatible
804
806
// with crates depending on them, we can't throw an error here.
805
807
Target :: Field | Target :: Arm | Target :: MacroDef => {
806
- self . inline_attr_str_error_with_macro_def ( hir_id, attr . span ( ) , "non_exhaustive" ) ;
808
+ self . inline_attr_str_error_with_macro_def ( hir_id, attr_span , "non_exhaustive" ) ;
807
809
}
808
810
_ => {
809
- self . dcx ( ) . emit_err ( errors:: NonExhaustiveWrongLocation {
810
- attr_span : attr. span ( ) ,
811
- defn_span : span,
812
- } ) ;
811
+ self . dcx ( )
812
+ . emit_err ( errors:: NonExhaustiveWrongLocation { attr_span, defn_span : span } ) ;
813
813
}
814
814
}
815
815
}
0 commit comments