@@ -188,6 +188,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
188188 Attribute :: Parsed ( AttributeKind :: TrackCaller ( attr_span) ) => {
189189 self . check_track_caller ( hir_id, * attr_span, attrs, span, target)
190190 }
191+ Attribute :: Parsed ( AttributeKind :: NonExhaustive ( attr_span) ) => {
192+ self . check_non_exhaustive ( hir_id, * attr_span, span, target, item)
193+ }
191194 Attribute :: Parsed (
192195 AttributeKind :: RustcLayoutScalarValidRangeStart ( _num, attr_span)
193196 | AttributeKind :: RustcLayoutScalarValidRangeEnd ( _num, attr_span) ,
@@ -228,7 +231,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
228231 [ sym:: no_sanitize, ..] => {
229232 self . check_no_sanitize ( attr, span, target)
230233 }
231- [ sym:: non_exhaustive, ..] => self . check_non_exhaustive ( hir_id, attr, span, target, item) ,
232234 [ sym:: marker, ..] => self . check_marker ( hir_id, attr, span, target) ,
233235 [ sym:: target_feature, ..] => {
234236 self . check_target_feature ( hir_id, attr, span, target, attrs)
@@ -755,7 +757,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
755757 fn check_non_exhaustive (
756758 & self ,
757759 hir_id : HirId ,
758- attr : & Attribute ,
760+ attr_span : Span ,
759761 span : Span ,
760762 target : Target ,
761763 item : Option < ItemLike < ' _ > > ,
@@ -770,7 +772,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
770772 && fields. iter ( ) . any ( |f| f. default . is_some ( ) )
771773 {
772774 self . dcx ( ) . emit_err ( errors:: NonExhaustiveWithDefaultFieldValues {
773- attr_span : attr . span ( ) ,
775+ attr_span,
774776 defn_span : span,
775777 } ) ;
776778 }
@@ -781,13 +783,11 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
781783 // erroneously allowed it and some crates used it accidentally, to be compatible
782784 // with crates depending on them, we can't throw an error here.
783785 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" ) ;
785787 }
786788 _ => {
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 } ) ;
791791 }
792792 }
793793 }
0 commit comments