@@ -9,7 +9,7 @@ use std::cell::Cell;
99use std:: collections:: hash_map:: Entry ;
1010
1111use rustc_abi:: { Align , ExternAbi , Size } ;
12- use rustc_ast:: { AttrStyle , LitKind , MetaItemInner , MetaItemKind , MetaItemLit , ast} ;
12+ use rustc_ast:: { AttrStyle , LitKind , MetaItemInner , MetaItemKind , ast} ;
1313use rustc_attr_data_structures:: { AttributeKind , InlineAttr , ReprAttr , find_attr} ;
1414use rustc_data_structures:: fx:: FxHashMap ;
1515use rustc_errors:: { Applicability , DiagCtxtHandle , IntoDiagArg , MultiSpan , StashKey } ;
@@ -183,6 +183,10 @@ 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 (
187+ AttributeKind :: RustcLayoutScalarValidRangeStart ( _num, attr_span)
188+ | AttributeKind :: RustcLayoutScalarValidRangeEnd ( _num, attr_span) ,
189+ ) => self . check_rustc_layout_scalar_valid_range ( * attr_span, span, target) ,
186190 Attribute :: Parsed (
187191 AttributeKind :: BodyStability { .. }
188192 | AttributeKind :: ConstStabilityIndirect
@@ -228,10 +232,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
228232 & mut doc_aliases,
229233 ) ,
230234 [ sym:: no_link, ..] => self . check_no_link ( hir_id, attr, span, target) ,
231- [ sym:: rustc_layout_scalar_valid_range_start, ..]
232- | [ sym:: rustc_layout_scalar_valid_range_end, ..] => {
233- self . check_rustc_layout_scalar_valid_range ( attr, span, target)
234- }
235235 [ sym:: debugger_visualizer, ..] => self . check_debugger_visualizer ( attr, target) ,
236236 [ sym:: rustc_std_internal_symbol, ..] => {
237237 self . check_rustc_std_internal_symbol ( attr, span, target)
@@ -1675,24 +1675,11 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
16751675 }
16761676 }
16771677
1678- fn check_rustc_layout_scalar_valid_range ( & self , attr : & Attribute , span : Span , target : Target ) {
1678+ fn check_rustc_layout_scalar_valid_range ( & self , attr_span : Span , span : Span , target : Target ) {
16791679 if target != Target :: Struct {
1680- self . dcx ( ) . emit_err ( errors:: RustcLayoutScalarValidRangeNotStruct {
1681- attr_span : attr. span ( ) ,
1682- span,
1683- } ) ;
1680+ self . dcx ( ) . emit_err ( errors:: RustcLayoutScalarValidRangeNotStruct { attr_span, span } ) ;
16841681 return ;
16851682 }
1686-
1687- let Some ( list) = attr. meta_item_list ( ) else {
1688- return ;
1689- } ;
1690-
1691- if !matches ! ( & list[ ..] , & [ MetaItemInner :: Lit ( MetaItemLit { kind: LitKind :: Int ( ..) , .. } ) ] ) {
1692- self . tcx
1693- . dcx ( )
1694- . emit_err ( errors:: RustcLayoutScalarValidRangeArg { attr_span : attr. span ( ) } ) ;
1695- }
16961683 }
16971684
16981685 /// Checks if `#[rustc_legacy_const_generics]` is applied to a function and has a valid argument.
0 commit comments