Skip to content

Commit 09e42bc

Browse files
committed
Add code to invalid ABI error
1 parent 6ec1b62 commit 09e42bc

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

src/libsyntax/diagnostic_list.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,5 @@ register_diagnostics! {
397397
E0630, // rustc_const_unstable attribute must be paired with stable/unstable attribute
398398
E0693, // incorrect `repr(align)` attribute format
399399
E0694, // an unknown tool name found in scoped attributes
400+
E0697, // invalid ABI
400401
}

src/libsyntax/parse/parser.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6535,12 +6535,15 @@ impl<'a> Parser<'a> {
65356535
Some(abi) => Ok(Some(abi)),
65366536
None => {
65376537
let prev_span = self.prev_span;
6538-
self.span_err(
6538+
let mut err = struct_span_err!(
6539+
self.sess.span_diagnostic,
65396540
prev_span,
6540-
&format!("invalid ABI: expected one of [{}], \
6541-
found `{}`",
6542-
abi::all_names().join(", "),
6543-
s));
6541+
E0697,
6542+
"invalid ABI: found `{}`",
6543+
s);
6544+
err.span_label(prev_span, "invalid ABI");
6545+
err.help(&format!("valid ABIs: {}", abi::all_names().join(", ")));
6546+
err.emit();
65446547
Ok(None)
65456548
}
65466549
}
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
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 `路濫狼á́́`
1+
error[E0697]: invalid ABI: found `路濫狼á́́`
22
--> $DIR/unicode.rs:11:8
33
|
44
LL | extern "路濫狼á́́" fn foo() {} //~ ERROR invalid ABI
5-
| ^^^^^^^^^
5+
| ^^^^^^^^^ invalid ABI
6+
|
7+
= 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
68

79
error: aborting due to previous error
810

11+
For more information about this error, try `rustc --explain E0697`.

0 commit comments

Comments
 (0)