@@ -183,6 +183,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
183183 Attribute :: Parsed ( AttributeKind :: TrackCaller ( attr_span) ) => {
184184 self . check_track_caller ( hir_id, * attr_span, attrs, span, target)
185185 }
186+ Attribute :: Parsed ( AttributeKind :: NonExhaustive ( attr_span) ) => {
187+ self . check_non_exhaustive ( hir_id, * attr_span, span, target, item)
188+ }
186189 Attribute :: Parsed (
187190 AttributeKind :: BodyStability { .. }
188191 | AttributeKind :: ConstStabilityIndirect
@@ -213,7 +216,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
213216 [ sym:: no_sanitize, ..] => {
214217 self . check_no_sanitize ( attr, span, target)
215218 }
216- [ sym:: non_exhaustive, ..] => self . check_non_exhaustive ( hir_id, attr, span, target, item) ,
217219 [ sym:: marker, ..] => self . check_marker ( hir_id, attr, span, target) ,
218220 [ sym:: target_feature, ..] => {
219221 self . check_target_feature ( hir_id, attr, span, target, attrs)
@@ -749,7 +751,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
749751 fn check_non_exhaustive (
750752 & self ,
751753 hir_id : HirId ,
752- attr : & Attribute ,
754+ attr_span : Span ,
753755 span : Span ,
754756 target : Target ,
755757 item : Option < ItemLike < ' _ > > ,
@@ -764,7 +766,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
764766 && fields. iter ( ) . any ( |f| f. default . is_some ( ) )
765767 {
766768 self . dcx ( ) . emit_err ( errors:: NonExhaustiveWithDefaultFieldValues {
767- attr_span : attr . span ( ) ,
769+ attr_span,
768770 defn_span : span,
769771 } ) ;
770772 }
@@ -775,13 +777,11 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
775777 // erroneously allowed it and some crates used it accidentally, to be compatible
776778 // with crates depending on them, we can't throw an error here.
777779 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" ) ;
779781 }
780782 _ => {
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 } ) ;
785785 }
786786 }
787787 }
0 commit comments