@@ -194,6 +194,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
194194 Attribute :: Parsed ( AttributeKind :: TrackCaller ( attr_span) ) => {
195195 self . check_track_caller ( hir_id, * attr_span, attrs, span, target)
196196 }
197+ Attribute :: Parsed ( AttributeKind :: NonExhaustive ( attr_span) ) => {
198+ self . check_non_exhaustive ( hir_id, * attr_span, span, target, item)
199+ }
197200 Attribute :: Parsed (
198201 AttributeKind :: RustcLayoutScalarValidRangeStart ( _num, attr_span)
199202 | AttributeKind :: RustcLayoutScalarValidRangeEnd ( _num, attr_span) ,
@@ -237,7 +240,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
237240 [ sym:: no_sanitize, ..] => {
238241 self . check_no_sanitize ( attr, span, target)
239242 }
240- [ sym:: non_exhaustive, ..] => self . check_non_exhaustive ( hir_id, attr, span, target, item) ,
241243 [ sym:: marker, ..] => self . check_marker ( hir_id, attr, span, target) ,
242244 [ sym:: thread_local, ..] => self . check_thread_local ( attr, span, target) ,
243245 [ sym:: doc, ..] => self . check_doc_attrs (
@@ -779,7 +781,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
779781 fn check_non_exhaustive (
780782 & self ,
781783 hir_id : HirId ,
782- attr : & Attribute ,
784+ attr_span : Span ,
783785 span : Span ,
784786 target : Target ,
785787 item : Option < ItemLike < ' _ > > ,
@@ -794,7 +796,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
794796 && fields. iter ( ) . any ( |f| f. default . is_some ( ) )
795797 {
796798 self . dcx ( ) . emit_err ( errors:: NonExhaustiveWithDefaultFieldValues {
797- attr_span : attr . span ( ) ,
799+ attr_span,
798800 defn_span : span,
799801 } ) ;
800802 }
@@ -805,13 +807,11 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
805807 // erroneously allowed it and some crates used it accidentally, to be compatible
806808 // with crates depending on them, we can't throw an error here.
807809 Target :: Field | Target :: Arm | Target :: MacroDef => {
808- self . inline_attr_str_error_with_macro_def ( hir_id, attr . span ( ) , "non_exhaustive" ) ;
810+ self . inline_attr_str_error_with_macro_def ( hir_id, attr_span , "non_exhaustive" ) ;
809811 }
810812 _ => {
811- self . dcx ( ) . emit_err ( errors:: NonExhaustiveWrongLocation {
812- attr_span : attr. span ( ) ,
813- defn_span : span,
814- } ) ;
813+ self . dcx ( )
814+ . emit_err ( errors:: NonExhaustiveWrongLocation { attr_span, defn_span : span } ) ;
815815 }
816816 }
817817 }
0 commit comments