@@ -7,20 +7,20 @@ use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};
77
88/// Parse #[repr(...)] forms.
99///
10- /// Valid repr contents: any of the primitive integral type names (see
11- /// `int_type_of_word`, below) to specify enum discriminant type; `C`, to use
12- /// the same discriminant size that the corresponding C enum would or C
13- /// structure layout, `packed` to remove padding, and `transparent` to delegate representation
14- /// concerns to the only non-ZST field.
15- // FIXME(jdonszelmann): is a vec the right representation here even? isn't it just a struct?
10+ /// Valid repr contents:
11+ /// * any of the primitive integral type names to specify enum discriminant type
12+ /// * `Rust`, to use the default `Rust` layout of the type
13+ /// * `C`, to use the same layout for the type that C would use
14+ /// * `align(...)`, to change the alignment requirements of the type
15+ /// * `packed`, to remove padding
16+ /// * `transparent`, to delegate representation concerns to the only non-ZST field.
1617pub ( crate ) struct ReprParser ;
1718
1819impl CombineAttributeParser for ReprParser {
1920 type Item = ( ReprAttr , Span ) ;
2021 const PATH : & [ Symbol ] = & [ sym:: repr] ;
2122 const CONVERT : ConvertFn < Self :: Item > =
2223 |items, first_span| AttributeKind :: Repr { reprs : items, first_span } ;
23- // FIXME(jdonszelmann): never used
2424 const TEMPLATE : AttributeTemplate = template ! (
2525 List : & [ "C" , "Rust" , "transparent" , "align(...)" , "packed(...)" , "<integer type>" ] ,
2626 "https://doc.rust-lang.org/reference/type-layout.html#representations"
@@ -30,29 +30,24 @@ impl CombineAttributeParser for ReprParser {
3030 cx : & mut AcceptContext < ' _ , ' _ > ,
3131 args : & ArgParser ,
3232 ) -> impl IntoIterator < Item = Self :: Item > {
33- let mut reprs = Vec :: new ( ) ;
34-
3533 let Some ( list) = cx. expect_list ( args, cx. attr_span ) else {
36- return reprs ;
34+ return vec ! [ ] ;
3735 } ;
3836
3937 if list. is_empty ( ) {
4038 let attr_span = cx. attr_span ;
4139 cx. adcx ( ) . warn_empty_attribute ( attr_span) ;
42- return reprs ;
40+ return vec ! [ ] ;
4341 }
4442
43+ let mut reprs = Vec :: new ( ) ;
4544 for param in list. mixed ( ) {
46- if let Some ( _ ) = param. as_lit ( ) {
47- cx. emit_err ( session_diagnostics :: ReprIdent { span : cx . attr_span } ) ;
45+ let Some ( item ) = param. meta_item ( ) else {
46+ cx. adcx ( ) . expected_identifier ( param . span ( ) ) ;
4847 continue ;
49- }
50-
51- reprs. extend (
52- param. meta_item ( ) . and_then ( |mi| parse_repr ( cx, & mi) ) . map ( |r| ( r, param. span ( ) ) ) ,
53- ) ;
48+ } ;
49+ reprs. extend ( parse_repr ( cx, & item) . map ( |r| ( r, param. span ( ) ) ) ) ;
5450 }
55-
5651 reprs
5752 }
5853
0 commit comments