@@ -183,6 +183,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
183
183
Attribute :: Parsed ( AttributeKind :: TrackCaller ( attr_span) ) => {
184
184
self . check_track_caller ( hir_id, * attr_span, attrs, span, target)
185
185
}
186
+ Attribute :: Parsed ( AttributeKind :: NonExhaustive ( attr_span) ) => {
187
+ self . check_non_exhaustive ( hir_id, * attr_span, span, target, item)
188
+ }
186
189
Attribute :: Parsed (
187
190
AttributeKind :: BodyStability { .. }
188
191
| AttributeKind :: ConstStabilityIndirect
@@ -213,7 +216,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
213
216
[ sym:: no_sanitize, ..] => {
214
217
self . check_no_sanitize ( attr, span, target)
215
218
}
216
- [ sym:: non_exhaustive, ..] => self . check_non_exhaustive ( hir_id, attr, span, target, item) ,
217
219
[ sym:: marker, ..] => self . check_marker ( hir_id, attr, span, target) ,
218
220
[ sym:: target_feature, ..] => {
219
221
self . check_target_feature ( hir_id, attr, span, target, attrs)
@@ -749,7 +751,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
749
751
fn check_non_exhaustive (
750
752
& self ,
751
753
hir_id : HirId ,
752
- attr : & Attribute ,
754
+ attr_span : Span ,
753
755
span : Span ,
754
756
target : Target ,
755
757
item : Option < ItemLike < ' _ > > ,
@@ -764,7 +766,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
764
766
&& fields. iter ( ) . any ( |f| f. default . is_some ( ) )
765
767
{
766
768
self . dcx ( ) . emit_err ( errors:: NonExhaustiveWithDefaultFieldValues {
767
- attr_span : attr . span ( ) ,
769
+ attr_span,
768
770
defn_span : span,
769
771
} ) ;
770
772
}
@@ -775,13 +777,11 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
775
777
// erroneously allowed it and some crates used it accidentally, to be compatible
776
778
// with crates depending on them, we can't throw an error here.
777
779
Target :: Field | Target :: Arm | Target :: MacroDef => {
778
- self . inline_attr_str_error_with_macro_def ( hir_id, attr . span ( ) , "non_exhaustive" ) ;
780
+ self . inline_attr_str_error_with_macro_def ( hir_id, attr_span , "non_exhaustive" ) ;
779
781
}
780
782
_ => {
781
- self . dcx ( ) . emit_err ( errors:: NonExhaustiveWrongLocation {
782
- attr_span : attr. span ( ) ,
783
- defn_span : span,
784
- } ) ;
783
+ self . dcx ( )
784
+ . emit_err ( errors:: NonExhaustiveWrongLocation { attr_span, defn_span : span } ) ;
785
785
}
786
786
}
787
787
}
0 commit comments