@@ -41,9 +41,7 @@ impl CombineAttributeGroup for ReprGroup {
41
41
42
42
for param in list. mixed ( ) {
43
43
if let Some ( _) = param. lit ( ) {
44
- cx. emit_err ( session_diagnostics:: ReprIdent {
45
- span : cx. attr_span ,
46
- } ) ;
44
+ cx. emit_err ( session_diagnostics:: ReprIdent { span : cx. attr_span } ) ;
47
45
continue ;
48
46
}
49
47
@@ -57,22 +55,21 @@ impl CombineAttributeGroup for ReprGroup {
57
55
58
56
macro_rules! int_pat {
59
57
( ) => {
60
- sym:: i8
61
- | sym:: u8
62
- | sym:: i16
63
- | sym:: u16
64
- | sym:: i32
65
- | sym:: u32
66
- | sym:: i64
67
- | sym:: u64
68
- | sym:: i128
69
- | sym:: u128
70
- | sym:: isize
71
- | sym:: usize
58
+ sym:: i8
59
+ | sym:: u8
60
+ | sym:: i16
61
+ | sym:: u16
62
+ | sym:: i32
63
+ | sym:: u32
64
+ | sym:: i64
65
+ | sym:: u64
66
+ | sym:: i128
67
+ | sym:: u128
68
+ | sym:: isize
69
+ | sym:: usize
72
70
} ;
73
71
}
74
72
75
- // TODO: inline
76
73
fn int_type_of_word ( s : Symbol ) -> Option < IntType > {
77
74
use IntType :: * ;
78
75
@@ -93,27 +90,26 @@ fn int_type_of_word(s: Symbol) -> Option<IntType> {
93
90
}
94
91
}
95
92
96
- fn parse_repr (
97
- cx : & AttributeAcceptContext < ' _ > ,
98
- param : & MetaItemParser < ' _ > ,
99
- ) -> Option < ReprAttr > {
93
+ fn parse_repr ( cx : & AttributeAcceptContext < ' _ > , param : & MetaItemParser < ' _ > ) -> Option < ReprAttr > {
100
94
use ReprAttr :: * ;
101
95
102
96
// FIXME(jdonszelmann): invert the parsing here to match on the word first and then the
103
97
// structure.
104
98
let ( ident, args) = param. word_or_empty ( ) ;
105
99
106
100
match ( ident. name , args) {
107
- ( sym:: align, ArgParser :: NoArgs ) => {
101
+ ( sym:: align, ArgParser :: NoArgs ) => {
108
102
cx. emit_err ( session_diagnostics:: InvalidReprAlignNeedArg { span : ident. span } ) ;
109
103
None
110
104
}
111
105
( sym:: align, ArgParser :: List ( l) ) => parse_repr_align ( cx, l, param. span ( ) , AlignKind :: Align ) ,
112
106
113
107
( sym:: packed, ArgParser :: NoArgs ) => Some ( ReprPacked ( Align :: ONE ) ) ,
114
- ( sym:: packed, ArgParser :: List ( l) ) => parse_repr_align ( cx, l, param. span ( ) , AlignKind :: Packed ) ,
108
+ ( sym:: packed, ArgParser :: List ( l) ) => {
109
+ parse_repr_align ( cx, l, param. span ( ) , AlignKind :: Packed )
110
+ }
115
111
116
- ( sym:: align | sym:: packed, ArgParser :: NameValue ( l) ) => {
112
+ ( sym:: align | sym:: packed, ArgParser :: NameValue ( l) ) => {
117
113
cx. emit_err ( session_diagnostics:: IncorrectReprFormatGeneric {
118
114
span : param. span ( ) ,
119
115
// FIXME(jdonszelmann) can just be a string in the diag type
@@ -127,24 +123,19 @@ fn parse_repr(
127
123
None
128
124
}
129
125
130
- ( sym:: Rust , ArgParser :: NoArgs ) => {
131
- Some ( ReprRust )
132
- }
133
- ( sym:: C , ArgParser :: NoArgs ) => {
134
- Some ( ReprC )
135
- }
136
- ( sym:: simd, ArgParser :: NoArgs ) => {
137
- Some ( ReprSimd )
138
- }
139
- ( sym:: transparent, ArgParser :: NoArgs ) => {
140
- Some ( ReprTransparent )
141
- }
142
- ( i@int_pat ! ( ) , ArgParser :: NoArgs ) => {
126
+ ( sym:: Rust , ArgParser :: NoArgs ) => Some ( ReprRust ) ,
127
+ ( sym:: C , ArgParser :: NoArgs ) => Some ( ReprC ) ,
128
+ ( sym:: simd, ArgParser :: NoArgs ) => Some ( ReprSimd ) ,
129
+ ( sym:: transparent, ArgParser :: NoArgs ) => Some ( ReprTransparent ) ,
130
+ ( i @ int_pat ! ( ) , ArgParser :: NoArgs ) => {
143
131
// int_pat!() should make sure it always parses
144
132
Some ( ReprInt ( int_type_of_word ( i) . unwrap ( ) ) )
145
133
}
146
134
147
- ( sym:: Rust | sym:: C | sym:: simd | sym:: transparent | int_pat ! ( ) , ArgParser :: NameValue ( _) ) => {
135
+ (
136
+ sym:: Rust | sym:: C | sym:: simd | sym:: transparent | int_pat ! ( ) ,
137
+ ArgParser :: NameValue ( _) ,
138
+ ) => {
148
139
cx. emit_err ( session_diagnostics:: InvalidReprHintNoValue {
149
140
span : param. span ( ) ,
150
141
name : ident. to_string ( ) ,
@@ -168,10 +159,15 @@ fn parse_repr(
168
159
169
160
enum AlignKind {
170
161
Packed ,
171
- Align
162
+ Align ,
172
163
}
173
164
174
- fn parse_repr_align ( cx : & AttributeAcceptContext < ' _ > , list : & MetaItemListParser < ' _ > , param_span : Span , align_kind : AlignKind ) -> Option < ReprAttr > {
165
+ fn parse_repr_align (
166
+ cx : & AttributeAcceptContext < ' _ > ,
167
+ list : & MetaItemListParser < ' _ > ,
168
+ param_span : Span ,
169
+ align_kind : AlignKind ,
170
+ ) -> Option < ReprAttr > {
175
171
use AlignKind :: * ;
176
172
177
173
let Some ( align) = list. single ( ) else {
@@ -180,14 +176,15 @@ fn parse_repr_align(cx: &AttributeAcceptContext<'_>, list: &MetaItemListParser<'
180
176
cx. emit_err ( session_diagnostics:: IncorrectReprFormatPackedOneOrZeroArg {
181
177
span : param_span,
182
178
} ) ;
183
- } ,
179
+ }
184
180
Align => {
185
- cx. dcx ( )
186
- . emit_err ( session_diagnostics:: IncorrectReprFormatAlignOneArg { span : param_span } ) ;
181
+ cx. dcx ( ) . emit_err ( session_diagnostics:: IncorrectReprFormatAlignOneArg {
182
+ span : param_span,
183
+ } ) ;
187
184
}
188
185
}
189
186
190
- return None
187
+ return None ;
191
188
} ;
192
189
193
190
let Some ( lit) = align. lit ( ) else {
@@ -196,15 +193,15 @@ fn parse_repr_align(cx: &AttributeAcceptContext<'_>, list: &MetaItemListParser<'
196
193
cx. emit_err ( session_diagnostics:: IncorrectReprFormatPackedExpectInteger {
197
194
span : align. span ( ) ,
198
195
} ) ;
199
- } ,
196
+ }
200
197
Align => {
201
198
cx. emit_err ( session_diagnostics:: IncorrectReprFormatExpectInteger {
202
199
span : align. span ( ) ,
203
200
} ) ;
204
201
}
205
202
}
206
203
207
- return None
204
+ return None ;
208
205
} ;
209
206
210
207
match parse_alignment ( & lit. kind ) {
0 commit comments