@@ -289,23 +289,25 @@ fn parse_args<'a>(
289
289
Ok ( args)
290
290
}
291
291
292
- fn err_duplicate_option < ' a > ( p : & mut Parser < ' a > , span : Span ) {
293
- let mut err = if let Ok ( snippet) = p. sess . source_map ( ) . span_to_snippet ( span) {
294
- p. sess
295
- . span_diagnostic
296
- . struct_span_err ( span, & format ! ( "the `{}` option was already provided" , snippet) )
297
- } else {
298
- p. sess . span_diagnostic . struct_span_err ( span, "this option was already provided" )
299
- } ;
292
+ fn err_duplicate_option < ' a > ( p : & mut Parser < ' a > , symbol : Symbol , span : Span ) {
293
+ let mut err = p
294
+ . sess
295
+ . span_diagnostic
296
+ . struct_span_err ( span, & format ! ( "the `{}` option was already provided" , symbol) ) ;
300
297
err. span_label ( span, "remove this option" ) ;
301
298
err. emit ( ) ;
302
299
}
303
300
304
- fn try_set_option < ' a > ( p : & mut Parser < ' a > , args : & mut AsmArgs , option : ast:: InlineAsmOptions ) {
301
+ fn try_set_option < ' a > (
302
+ p : & mut Parser < ' a > ,
303
+ args : & mut AsmArgs ,
304
+ symbol : Symbol ,
305
+ option : ast:: InlineAsmOptions ,
306
+ ) {
305
307
if !args. option_is_set ( option) {
306
308
args. options |= option;
307
309
} else {
308
- err_duplicate_option ( p, p. prev_token . span ) ;
310
+ err_duplicate_option ( p, symbol , p. prev_token . span ) ;
309
311
}
310
312
}
311
313
@@ -316,20 +318,20 @@ fn parse_options<'a>(p: &mut Parser<'a>, args: &mut AsmArgs) -> Result<(), Diagn
316
318
317
319
while !p. eat ( & token:: CloseDelim ( token:: DelimToken :: Paren ) ) {
318
320
if p. eat ( & token:: Ident ( sym:: pure, false ) ) {
319
- try_set_option ( p, args, ast:: InlineAsmOptions :: PURE ) ;
321
+ try_set_option ( p, args, sym :: pure , ast:: InlineAsmOptions :: PURE ) ;
320
322
} else if p. eat ( & token:: Ident ( sym:: nomem, false ) ) {
321
- try_set_option ( p, args, ast:: InlineAsmOptions :: NOMEM ) ;
323
+ try_set_option ( p, args, sym :: nomem , ast:: InlineAsmOptions :: NOMEM ) ;
322
324
} else if p. eat ( & token:: Ident ( sym:: readonly, false ) ) {
323
- try_set_option ( p, args, ast:: InlineAsmOptions :: READONLY ) ;
325
+ try_set_option ( p, args, sym :: readonly , ast:: InlineAsmOptions :: READONLY ) ;
324
326
} else if p. eat ( & token:: Ident ( sym:: preserves_flags, false ) ) {
325
- try_set_option ( p, args, ast:: InlineAsmOptions :: PRESERVES_FLAGS ) ;
327
+ try_set_option ( p, args, sym :: preserves_flags , ast:: InlineAsmOptions :: PRESERVES_FLAGS ) ;
326
328
} else if p. eat ( & token:: Ident ( sym:: noreturn, false ) ) {
327
- try_set_option ( p, args, ast:: InlineAsmOptions :: NORETURN ) ;
329
+ try_set_option ( p, args, sym :: noreturn , ast:: InlineAsmOptions :: NORETURN ) ;
328
330
} else if p. eat ( & token:: Ident ( sym:: nostack, false ) ) {
329
- try_set_option ( p, args, ast:: InlineAsmOptions :: NOSTACK ) ;
331
+ try_set_option ( p, args, sym :: nostack , ast:: InlineAsmOptions :: NOSTACK ) ;
330
332
} else {
331
333
p. expect ( & token:: Ident ( sym:: att_syntax, false ) ) ?;
332
- try_set_option ( p, args, ast:: InlineAsmOptions :: ATT_SYNTAX ) ;
334
+ try_set_option ( p, args, sym :: att_syntax , ast:: InlineAsmOptions :: ATT_SYNTAX ) ;
333
335
}
334
336
335
337
// Allow trailing commas
0 commit comments