diff --git a/src/libsyntax/diagnostic_list.rs b/src/libsyntax/diagnostic_list.rs index ab8317bfa027..b6748c40fc43 100644 --- a/src/libsyntax/diagnostic_list.rs +++ b/src/libsyntax/diagnostic_list.rs @@ -397,4 +397,5 @@ register_diagnostics! { E0630, // rustc_const_unstable attribute must be paired with stable/unstable attribute E0693, // incorrect `repr(align)` attribute format E0694, // an unknown tool name found in scoped attributes + E0697, // invalid ABI } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1735951da2f3..f38f4cc71373 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6535,12 +6535,15 @@ impl<'a> Parser<'a> { Some(abi) => Ok(Some(abi)), None => { let prev_span = self.prev_span; - self.span_err( + let mut err = struct_span_err!( + self.sess.span_diagnostic, prev_span, - &format!("invalid ABI: expected one of [{}], \ - found `{}`", - abi::all_names().join(", "), - s)); + E0697, + "invalid ABI: found `{}`", + s); + err.span_label(prev_span, "invalid ABI"); + err.help(&format!("valid ABIs: {}", abi::all_names().join(", "))); + err.emit(); Ok(None) } } diff --git a/src/test/ui/codemap_tests/unicode.stderr b/src/test/ui/codemap_tests/unicode.stderr index b9b03c9b9ec6..d2e79a0b47d3 100644 --- a/src/test/ui/codemap_tests/unicode.stderr +++ b/src/test/ui/codemap_tests/unicode.stderr @@ -1,8 +1,11 @@ -error: invalid ABI: expected one of [cdecl, stdcall, fastcall, vectorcall, thiscall, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, Rust, C, system, rust-intrinsic, rust-call, platform-intrinsic, unadjusted], found `路濫狼á́́` +error[E0697]: invalid ABI: found `路濫狼á́́` --> $DIR/unicode.rs:11:8 | LL | extern "路濫狼á́́" fn foo() {} //~ ERROR invalid ABI - | ^^^^^^^^^ + | ^^^^^^^^^ invalid ABI + | + = help: valid ABIs: cdecl, stdcall, fastcall, vectorcall, thiscall, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, Rust, C, system, rust-intrinsic, rust-call, platform-intrinsic, unadjusted error: aborting due to previous error +For more information about this error, try `rustc --explain E0697`.