@@ -159,7 +159,7 @@ fn match_attr_flags(attr_flags: &mut AttrFlags, attr: ast::Meta) -> ControlFlow<
159159 None => match & * first_segment {
160160 "deprecated" => attr_flags. insert ( AttrFlags :: IS_DEPRECATED ) ,
161161 "doc" => extract_doc_tt_attr ( attr_flags, tt) ,
162- "repr" => attr_flags. insert ( AttrFlags :: HAS_REPR ) ,
162+ "repr" | "rustc_scalable_vector" => attr_flags. insert ( AttrFlags :: HAS_REPR ) ,
163163 "target_feature" => attr_flags. insert ( AttrFlags :: HAS_TARGET_FEATURE ) ,
164164 "proc_macro_derive" | "rustc_builtin_macro" => {
165165 attr_flags. insert ( AttrFlags :: IS_DERIVE_OR_BUILTIN_MACRO )
@@ -217,6 +217,7 @@ fn match_attr_flags(attr_flags: &mut AttrFlags, attr: ast::Meta) -> ControlFlow<
217217 "rustc_allow_incoherent_impl" => {
218218 attr_flags. insert ( AttrFlags :: RUSTC_ALLOW_INCOHERENT_IMPL )
219219 }
220+ "rustc_scalable_vector" => attr_flags. insert ( AttrFlags :: HAS_REPR ) ,
220221 "fundamental" => attr_flags. insert ( AttrFlags :: FUNDAMENTAL ) ,
221222 "no_std" => attr_flags. insert ( AttrFlags :: IS_NO_STD ) ,
222223 "may_dangle" => attr_flags. insert ( AttrFlags :: MAY_DANGLE ) ,
@@ -724,14 +725,40 @@ impl AttrFlags {
724725 fn repr ( db : & dyn DefDatabase , owner : AdtId ) -> Option < ReprOptions > {
725726 let mut result = None ;
726727 collect_attrs :: < Infallible > ( db, owner. into ( ) , |attr| {
727- if let ast:: Meta :: TokenTreeMeta ( attr) = attr
728- && attr. path ( ) . is1 ( "repr" )
728+ let mut current = None ;
729+ if let ast:: Meta :: TokenTreeMeta ( attr) = & attr
730+ && let Some ( path) = attr. path ( )
729731 && let Some ( tt) = attr. token_tree ( )
730- && let Some ( repr) = parse_repr_tt ( & tt)
731732 {
733+ if path. is1 ( "repr" )
734+ && let Some ( repr) = parse_repr_tt ( & tt)
735+ {
736+ current = Some ( repr) ;
737+ } else if path. is1 ( "rustc_scalable_vector" )
738+ && let mut tt = TokenTreeChildren :: new ( & tt)
739+ && let Some ( NodeOrToken :: Token ( scalable) ) = tt. next ( )
740+ && let Some ( scalable) = ast:: IntNumber :: cast ( scalable)
741+ && let Ok ( scalable) = scalable. value ( )
742+ && let Ok ( scalable) = scalable. try_into ( )
743+ {
744+ current = Some ( ReprOptions {
745+ scalable : Some ( rustc_abi:: ScalableElt :: ElementCount ( scalable) ) ,
746+ ..ReprOptions :: default ( )
747+ } ) ;
748+ }
749+ } else if let ast:: Meta :: PathMeta ( attr) = & attr
750+ && attr. path ( ) . is1 ( "rustc_scalable_vector" )
751+ {
752+ current = Some ( ReprOptions {
753+ scalable : Some ( rustc_abi:: ScalableElt :: Container ) ,
754+ ..ReprOptions :: default ( )
755+ } ) ;
756+ }
757+
758+ if let Some ( current) = current {
732759 match & mut result {
733- Some ( existing) => merge_repr ( existing, repr ) ,
734- None => result = Some ( repr ) ,
760+ Some ( existing) => merge_repr ( existing, current ) ,
761+ None => result = Some ( current ) ,
735762 }
736763 }
737764 ControlFlow :: Continue ( ( ) )
@@ -1114,7 +1141,7 @@ impl AttrFlags {
11141141}
11151142
11161143fn merge_repr ( this : & mut ReprOptions , other : ReprOptions ) {
1117- let ReprOptions { int, align, pack, flags, field_shuffle_seed : _ } = this;
1144+ let ReprOptions { int, align, pack, flags, scalable , field_shuffle_seed : _ } = this;
11181145 flags. insert ( other. flags ) ;
11191146 * align = ( * align) . max ( other. align ) ;
11201147 * pack = match ( * pack, other. pack ) {
@@ -1124,6 +1151,9 @@ fn merge_repr(this: &mut ReprOptions, other: ReprOptions) {
11241151 if other. int . is_some ( ) {
11251152 * int = other. int ;
11261153 }
1154+ if other. scalable . is_some ( ) {
1155+ * scalable = other. scalable ;
1156+ }
11271157}
11281158
11291159fn parse_repr_tt ( tt : & ast:: TokenTree ) -> Option < ReprOptions > {
0 commit comments