@@ -16,7 +16,7 @@ struct AsmArgs {
16
16
named_args : FxHashMap < Symbol , usize > ,
17
17
reg_args : FxHashSet < usize > ,
18
18
options : ast:: InlineAsmOptions ,
19
- options_spans : Option < Vec < Span > > ,
19
+ options_spans : Vec < Span > ,
20
20
}
21
21
22
22
fn parse_args < ' a > (
@@ -59,7 +59,7 @@ fn parse_args<'a>(
59
59
named_args : FxHashMap :: default ( ) ,
60
60
reg_args : FxHashSet :: default ( ) ,
61
61
options : ast:: InlineAsmOptions :: empty ( ) ,
62
- options_spans : None ,
62
+ options_spans : vec ! [ ] ,
63
63
} ;
64
64
65
65
let mut allow_templates = true ;
@@ -174,9 +174,9 @@ fn parse_args<'a>(
174
174
175
175
// Validate the order of named, positional & explicit register operands and options. We do
176
176
// this at the end once we have the full span of the argument available.
177
- if let Some ( ref options_spans) = args . options_spans {
177
+ if args . options_spans . len ( ) > 0 {
178
178
ecx. struct_span_err ( span, "arguments are not allowed after options" )
179
- . span_labels ( options_spans. clone ( ) , "previous options" )
179
+ . span_labels ( args . options_spans . clone ( ) , "previous options" )
180
180
. span_label ( span, "argument" )
181
181
. emit ( ) ;
182
182
}
@@ -227,21 +227,21 @@ fn parse_args<'a>(
227
227
if args. options . contains ( ast:: InlineAsmOptions :: NOMEM )
228
228
&& args. options . contains ( ast:: InlineAsmOptions :: READONLY )
229
229
{
230
- let spans = args. options_spans . clone ( ) . unwrap ( ) ;
230
+ let spans = args. options_spans . clone ( ) ;
231
231
ecx. struct_span_err ( spans, "the `nomem` and `readonly` options are mutually exclusive" )
232
232
. emit ( ) ;
233
233
}
234
234
if args. options . contains ( ast:: InlineAsmOptions :: PURE )
235
235
&& args. options . contains ( ast:: InlineAsmOptions :: NORETURN )
236
236
{
237
- let spans = args. options_spans . clone ( ) . unwrap ( ) ;
237
+ let spans = args. options_spans . clone ( ) ;
238
238
ecx. struct_span_err ( spans, "the `pure` and `noreturn` options are mutually exclusive" )
239
239
. emit ( ) ;
240
240
}
241
241
if args. options . contains ( ast:: InlineAsmOptions :: PURE )
242
242
&& !args. options . intersects ( ast:: InlineAsmOptions :: NOMEM | ast:: InlineAsmOptions :: READONLY )
243
243
{
244
- let span = args. options_spans . clone ( ) . unwrap ( ) ;
244
+ let span = args. options_spans . clone ( ) ;
245
245
ecx. struct_span_err (
246
246
span,
247
247
"the `pure` option must be combined with either `nomem` or `readonly`" ,
@@ -267,7 +267,7 @@ fn parse_args<'a>(
267
267
}
268
268
if args. options . contains ( ast:: InlineAsmOptions :: PURE ) && !have_real_output {
269
269
ecx. struct_span_err (
270
- args. options_spans . clone ( ) . unwrap ( ) ,
270
+ args. options_spans . clone ( ) ,
271
271
"asm with `pure` option must have at least one output" ,
272
272
)
273
273
. emit ( ) ;
@@ -314,11 +314,7 @@ fn parse_options<'a>(p: &mut Parser<'a>, args: &mut AsmArgs) -> Result<(), Diagn
314
314
}
315
315
316
316
let new_span = span_start. to ( p. prev_token . span ) ;
317
- if let Some ( options_spans) = & mut args. options_spans {
318
- options_spans. push ( new_span) ;
319
- } else {
320
- args. options_spans = Some ( vec ! [ new_span] ) ;
321
- }
317
+ args. options_spans . push ( new_span) ;
322
318
323
319
Ok ( ( ) )
324
320
}
0 commit comments