@@ -188,6 +188,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
188
188
Attribute :: Parsed ( AttributeKind :: TrackCaller ( attr_span) ) => {
189
189
self . check_track_caller ( hir_id, * attr_span, attrs, span, target)
190
190
}
191
+ Attribute :: Parsed ( AttributeKind :: NonExhaustive ( attr_span) ) => {
192
+ self . check_non_exhaustive ( hir_id, * attr_span, span, target, item)
193
+ }
191
194
Attribute :: Parsed (
192
195
AttributeKind :: RustcLayoutScalarValidRangeStart ( _num, attr_span)
193
196
| AttributeKind :: RustcLayoutScalarValidRangeEnd ( _num, attr_span) ,
@@ -228,7 +231,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
228
231
[ sym:: no_sanitize, ..] => {
229
232
self . check_no_sanitize ( attr, span, target)
230
233
}
231
- [ sym:: non_exhaustive, ..] => self . check_non_exhaustive ( hir_id, attr, span, target, item) ,
232
234
[ sym:: marker, ..] => self . check_marker ( hir_id, attr, span, target) ,
233
235
[ sym:: target_feature, ..] => {
234
236
self . check_target_feature ( hir_id, attr, span, target, attrs)
@@ -755,7 +757,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
755
757
fn check_non_exhaustive (
756
758
& self ,
757
759
hir_id : HirId ,
758
- attr : & Attribute ,
760
+ attr_span : Span ,
759
761
span : Span ,
760
762
target : Target ,
761
763
item : Option < ItemLike < ' _ > > ,
@@ -770,7 +772,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
770
772
&& fields. iter ( ) . any ( |f| f. default . is_some ( ) )
771
773
{
772
774
self . dcx ( ) . emit_err ( errors:: NonExhaustiveWithDefaultFieldValues {
773
- attr_span : attr . span ( ) ,
775
+ attr_span,
774
776
defn_span : span,
775
777
} ) ;
776
778
}
@@ -781,13 +783,11 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
781
783
// erroneously allowed it and some crates used it accidentally, to be compatible
782
784
// with crates depending on them, we can't throw an error here.
783
785
Target :: Field | Target :: Arm | Target :: MacroDef => {
784
- self . inline_attr_str_error_with_macro_def ( hir_id, attr . span ( ) , "non_exhaustive" ) ;
786
+ self . inline_attr_str_error_with_macro_def ( hir_id, attr_span , "non_exhaustive" ) ;
785
787
}
786
788
_ => {
787
- self . dcx ( ) . emit_err ( errors:: NonExhaustiveWrongLocation {
788
- attr_span : attr. span ( ) ,
789
- defn_span : span,
790
- } ) ;
789
+ self . dcx ( )
790
+ . emit_err ( errors:: NonExhaustiveWrongLocation { attr_span, defn_span : span } ) ;
791
791
}
792
792
}
793
793
}
0 commit comments