1
Fork 0

Make suggestion machine-applicable

This commit is contained in:
Camelid 2020-06-16 12:32:13 -07:00
parent f4dfc61e84
commit 4ba66970d8
4 changed files with 48 additions and 12 deletions

View file

@ -288,7 +288,12 @@ fn err_duplicate_option<'a>(p: &mut Parser<'a>, symbol: Symbol, span: Span) {
.sess .sess
.span_diagnostic .span_diagnostic
.struct_span_err(span, &format!("the `{}` option was already provided", symbol)); .struct_span_err(span, &format!("the `{}` option was already provided", symbol));
err.span_suggestion(span, "remove this option", String::new(), Applicability::Unspecified); err.span_suggestion(
span,
"remove this option",
String::new(),
Applicability::MachineApplicable,
);
err.emit(); err.emit();
} }
@ -301,7 +306,11 @@ fn try_set_option<'a>(
if !args.options.contains(option) { if !args.options.contains(option) {
args.options |= option; args.options |= option;
} else { } else {
err_duplicate_option(p, symbol, p.prev_token.span); let mut span = p.prev_token.span;
if p.look_ahead(0, |t| t == &token::Comma) {
span = span.to(p.token.span);
}
err_duplicate_option(p, symbol, span);
} }
} }

View file

@ -0,0 +1,26 @@
// only-x86_64
// run-rustfix
#![feature(asm)]
fn main() {
unsafe {
asm!("", options(nomem, ));
//~^ ERROR the `nomem` option was already provided
asm!("", options(att_syntax, ));
//~^ ERROR the `att_syntax` option was already provided
asm!("", options(nostack, att_syntax), options());
//~^ ERROR the `nostack` option was already provided
asm!("", options(nostack, ), options(), options());
//~^ ERROR the `nostack` option was already provided
//~| ERROR the `nostack` option was already provided
//~| ERROR the `nostack` option was already provided
asm!(
"",
options(nomem, noreturn),
options(att_syntax, ), //~ ERROR the `noreturn` option was already provided
options( nostack), //~ ERROR the `nomem` option was already provided
options(), //~ ERROR the `noreturn` option was already provided
);
}
}

View file

@ -1,4 +1,5 @@
// only-x86_64 // only-x86_64
// run-rustfix
#![feature(asm)] #![feature(asm)]

View file

@ -1,53 +1,53 @@
error: the `nomem` option was already provided error: the `nomem` option was already provided
--> $DIR/duplicate-options.rs:7:33 --> $DIR/duplicate-options.rs:8:33
| |
LL | asm!("", options(nomem, nomem)); LL | asm!("", options(nomem, nomem));
| ^^^^^ help: remove this option | ^^^^^ help: remove this option
error: the `att_syntax` option was already provided error: the `att_syntax` option was already provided
--> $DIR/duplicate-options.rs:9:38 --> $DIR/duplicate-options.rs:10:38
| |
LL | asm!("", options(att_syntax, att_syntax)); LL | asm!("", options(att_syntax, att_syntax));
| ^^^^^^^^^^ help: remove this option | ^^^^^^^^^^ help: remove this option
error: the `nostack` option was already provided error: the `nostack` option was already provided
--> $DIR/duplicate-options.rs:11:56 --> $DIR/duplicate-options.rs:12:56
| |
LL | asm!("", options(nostack, att_syntax), options(nostack)); LL | asm!("", options(nostack, att_syntax), options(nostack));
| ^^^^^^^ help: remove this option | ^^^^^^^ help: remove this option
error: the `nostack` option was already provided error: the `nostack` option was already provided
--> $DIR/duplicate-options.rs:13:35 --> $DIR/duplicate-options.rs:14:35
| |
LL | asm!("", options(nostack, nostack), options(nostack), options(nostack)); LL | asm!("", options(nostack, nostack), options(nostack), options(nostack));
| ^^^^^^^ help: remove this option | ^^^^^^^ help: remove this option
error: the `nostack` option was already provided error: the `nostack` option was already provided
--> $DIR/duplicate-options.rs:13:53 --> $DIR/duplicate-options.rs:14:53
| |
LL | asm!("", options(nostack, nostack), options(nostack), options(nostack)); LL | asm!("", options(nostack, nostack), options(nostack), options(nostack));
| ^^^^^^^ help: remove this option | ^^^^^^^ help: remove this option
error: the `nostack` option was already provided error: the `nostack` option was already provided
--> $DIR/duplicate-options.rs:13:71 --> $DIR/duplicate-options.rs:14:71
| |
LL | asm!("", options(nostack, nostack), options(nostack), options(nostack)); LL | asm!("", options(nostack, nostack), options(nostack), options(nostack));
| ^^^^^^^ help: remove this option | ^^^^^^^ help: remove this option
error: the `noreturn` option was already provided error: the `noreturn` option was already provided
--> $DIR/duplicate-options.rs:20:33 --> $DIR/duplicate-options.rs:21:33
| |
LL | options(att_syntax, noreturn), LL | options(att_syntax, noreturn),
| ^^^^^^^^ help: remove this option | ^^^^^^^^ help: remove this option
error: the `nomem` option was already provided error: the `nomem` option was already provided
--> $DIR/duplicate-options.rs:21:21 --> $DIR/duplicate-options.rs:22:21
| |
LL | options(nomem, nostack), LL | options(nomem, nostack),
| ^^^^^ help: remove this option | ^^^^^^ help: remove this option
error: the `noreturn` option was already provided error: the `noreturn` option was already provided
--> $DIR/duplicate-options.rs:22:21 --> $DIR/duplicate-options.rs:23:21
| |
LL | options(noreturn), LL | options(noreturn),
| ^^^^^^^^ help: remove this option | ^^^^^^^^ help: remove this option