Skip to content

Commit e5a639d

Browse files
authored
Rollup merge of #137771 - estebank:abi-sugg, r=compiler-errors
Tweak incorrect ABI suggestion and make suggestion verbose Provide a better suggestion message, and make the suggestion verbose. ``` error[E0703]: invalid ABI: found `riscv-interrupt` --> $DIR/riscv-discoverability-guidance.rs:17:8 | LL | extern "riscv-interrupt" fn isr() {} | ^^^^^^^^^^^^^^^^^ invalid ABI | = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions help: there's a similarly named valid ABI `riscv-interrupt-m` | LL | extern "riscv-interrupt-m" fn isr() {} | ++ ```
2 parents 472bc0e + 86945c0 commit e5a639d

File tree

6 files changed

+33
-24
lines changed

6 files changed

+33
-24
lines changed

compiler/rustc_ast_lowering/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ ast_lowering_invalid_abi_clobber_abi =
8888
invalid ABI for `clobber_abi`
8989
.note = the following ABIs are supported on this target: {$supported_abis}
9090
91-
ast_lowering_invalid_abi_suggestion = did you mean
91+
ast_lowering_invalid_abi_suggestion = there's a similarly named valid ABI `{$suggestion}`
9292
9393
ast_lowering_invalid_asm_template_modifier_const =
9494
asm template modifiers are not allowed for `const` arguments

compiler/rustc_ast_lowering/src/errors.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ pub(crate) struct TupleStructWithDefault {
4646
#[derive(Subdiagnostic)]
4747
#[suggestion(
4848
ast_lowering_invalid_abi_suggestion,
49-
code = "{suggestion}",
50-
applicability = "maybe-incorrect"
49+
code = "\"{suggestion}\"",
50+
applicability = "maybe-incorrect",
51+
style = "verbose"
5152
)]
5253
pub(crate) struct InvalidAbiSuggestion {
5354
#[primary_span]

compiler/rustc_ast_lowering/src/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1510,7 +1510,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15101510
span: abi.span,
15111511
suggestion: suggested_name.map(|suggested_name| InvalidAbiSuggestion {
15121512
span: abi.span,
1513-
suggestion: format!("\"{suggested_name}\""),
1513+
suggestion: suggested_name.to_string(),
15141514
}),
15151515
command: "rustc --print=calling-conventions".to_string(),
15161516
});

tests/ui/abi/riscv-discoverability-guidance.riscv32.stderr

+11-8
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,26 @@ error[E0703]: invalid ABI: found `riscv-interrupt`
22
--> $DIR/riscv-discoverability-guidance.rs:15:8
33
|
44
LL | extern "riscv-interrupt" fn isr() {}
5-
| ^^^^^^^^^^^^^^^^^
6-
| |
7-
| invalid ABI
8-
| help: did you mean: `"riscv-interrupt-m"`
5+
| ^^^^^^^^^^^^^^^^^ invalid ABI
96
|
107
= note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions
8+
help: there's a similarly named valid ABI `riscv-interrupt-m`
9+
|
10+
LL | extern "riscv-interrupt-m" fn isr() {}
11+
| ++
1112

1213
error[E0703]: invalid ABI: found `riscv-interrupt-u`
1314
--> $DIR/riscv-discoverability-guidance.rs:20:8
1415
|
1516
LL | extern "riscv-interrupt-u" fn isr_U() {}
16-
| ^^^^^^^^^^^^^^^^^^^
17-
| |
18-
| invalid ABI
19-
| help: did you mean: `"riscv-interrupt-m"`
17+
| ^^^^^^^^^^^^^^^^^^^ invalid ABI
2018
|
2119
= note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions
20+
help: there's a similarly named valid ABI `riscv-interrupt-m`
21+
|
22+
LL - extern "riscv-interrupt-u" fn isr_U() {}
23+
LL + extern "riscv-interrupt-m" fn isr_U() {}
24+
|
2225

2326
error: aborting due to 2 previous errors
2427

tests/ui/abi/riscv-discoverability-guidance.riscv64.stderr

+11-8
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,26 @@ error[E0703]: invalid ABI: found `riscv-interrupt`
22
--> $DIR/riscv-discoverability-guidance.rs:15:8
33
|
44
LL | extern "riscv-interrupt" fn isr() {}
5-
| ^^^^^^^^^^^^^^^^^
6-
| |
7-
| invalid ABI
8-
| help: did you mean: `"riscv-interrupt-m"`
5+
| ^^^^^^^^^^^^^^^^^ invalid ABI
96
|
107
= note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions
8+
help: there's a similarly named valid ABI `riscv-interrupt-m`
9+
|
10+
LL | extern "riscv-interrupt-m" fn isr() {}
11+
| ++
1112

1213
error[E0703]: invalid ABI: found `riscv-interrupt-u`
1314
--> $DIR/riscv-discoverability-guidance.rs:20:8
1415
|
1516
LL | extern "riscv-interrupt-u" fn isr_U() {}
16-
| ^^^^^^^^^^^^^^^^^^^
17-
| |
18-
| invalid ABI
19-
| help: did you mean: `"riscv-interrupt-m"`
17+
| ^^^^^^^^^^^^^^^^^^^ invalid ABI
2018
|
2119
= note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions
20+
help: there's a similarly named valid ABI `riscv-interrupt-m`
21+
|
22+
LL - extern "riscv-interrupt-u" fn isr_U() {}
23+
LL + extern "riscv-interrupt-m" fn isr_U() {}
24+
|
2225

2326
error: aborting due to 2 previous errors
2427

tests/ui/suggestions/abi-typo.stderr

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ error[E0703]: invalid ABI: found `cdedl`
22
--> $DIR/abi-typo.rs:2:8
33
|
44
LL | extern "cdedl" fn cdedl() {}
5-
| ^^^^^^^
6-
| |
7-
| invalid ABI
8-
| help: did you mean: `"cdecl"`
5+
| ^^^^^^^ invalid ABI
96
|
107
= note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions
8+
help: there's a similarly named valid ABI `cdecl`
9+
|
10+
LL - extern "cdedl" fn cdedl() {}
11+
LL + extern "cdecl" fn cdedl() {}
12+
|
1113

1214
error: aborting due to 1 previous error
1315

0 commit comments

Comments
 (0)