@@ -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) ,
@@ -234,7 +237,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
234237 [ sym:: no_sanitize, ..] => {
235238 self . check_no_sanitize ( attr, span, target)
236239 }
237- [ sym:: non_exhaustive, ..] => self . check_non_exhaustive ( hir_id, attr, span, target, item) ,
238240 [ sym:: marker, ..] => self . check_marker ( hir_id, attr, span, target) ,
239241 [ sym:: thread_local, ..] => self . check_thread_local ( attr, span, target) ,
240242 [ sym:: doc, ..] => self . check_doc_attrs (
@@ -777,7 +779,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
777779 fn check_non_exhaustive (
778780 & self ,
779781 hir_id : HirId ,
780- attr : & Attribute ,
782+ attr_span : Span ,
781783 span : Span ,
782784 target : Target ,
783785 item : Option < ItemLike < ' _ > > ,
@@ -792,7 +794,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
792794 && fields. iter ( ) . any ( |f| f. default . is_some ( ) )
793795 {
794796 self . dcx ( ) . emit_err ( errors:: NonExhaustiveWithDefaultFieldValues {
795- attr_span : attr . span ( ) ,
797+ attr_span,
796798 defn_span : span,
797799 } ) ;
798800 }
@@ -803,13 +805,11 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
803805 // erroneously allowed it and some crates used it accidentally, to be compatible
804806 // with crates depending on them, we can't throw an error here.
805807 Target :: Field | Target :: Arm | Target :: MacroDef => {
806- self . inline_attr_str_error_with_macro_def ( hir_id, attr . span ( ) , "non_exhaustive" ) ;
808+ self . inline_attr_str_error_with_macro_def ( hir_id, attr_span , "non_exhaustive" ) ;
807809 }
808810 _ => {
809- self . dcx ( ) . emit_err ( errors:: NonExhaustiveWrongLocation {
810- attr_span : attr. span ( ) ,
811- defn_span : span,
812- } ) ;
811+ self . dcx ( )
812+ . emit_err ( errors:: NonExhaustiveWrongLocation { attr_span, defn_span : span } ) ;
813813 }
814814 }
815815 }
0 commit comments