Tweak incorrect ABI suggestion

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() {}
   |                        ++
```
This commit is contained in:
Esteban Küber 2025-02-28 03:35:13 +00:00
parent f45d4acf1b
commit 86945c0a54
6 changed files with 33 additions and 24 deletions

View File

@ -88,7 +88,7 @@ ast_lowering_invalid_abi_clobber_abi =
invalid ABI for `clobber_abi` invalid ABI for `clobber_abi`
.note = the following ABIs are supported on this target: {$supported_abis} .note = the following ABIs are supported on this target: {$supported_abis}
ast_lowering_invalid_abi_suggestion = did you mean ast_lowering_invalid_abi_suggestion = there's a similarly named valid ABI `{$suggestion}`
ast_lowering_invalid_asm_template_modifier_const = ast_lowering_invalid_asm_template_modifier_const =
asm template modifiers are not allowed for `const` arguments asm template modifiers are not allowed for `const` arguments

View File

@ -46,8 +46,9 @@ pub(crate) struct TupleStructWithDefault {
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion( #[suggestion(
ast_lowering_invalid_abi_suggestion, ast_lowering_invalid_abi_suggestion,
code = "{suggestion}", code = "\"{suggestion}\"",
applicability = "maybe-incorrect" applicability = "maybe-incorrect",
style = "verbose"
)] )]
pub(crate) struct InvalidAbiSuggestion { pub(crate) struct InvalidAbiSuggestion {
#[primary_span] #[primary_span]

View File

@ -1510,7 +1510,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
span: abi.span, span: abi.span,
suggestion: suggested_name.map(|suggested_name| InvalidAbiSuggestion { suggestion: suggested_name.map(|suggested_name| InvalidAbiSuggestion {
span: abi.span, span: abi.span,
suggestion: format!("\"{suggested_name}\""), suggestion: suggested_name.to_string(),
}), }),
command: "rustc --print=calling-conventions".to_string(), command: "rustc --print=calling-conventions".to_string(),
}); });

View File

@ -2,23 +2,26 @@ error[E0703]: invalid ABI: found `riscv-interrupt`
--> $DIR/riscv-discoverability-guidance.rs:17:8 --> $DIR/riscv-discoverability-guidance.rs:17:8
| |
LL | extern "riscv-interrupt" fn isr() {} LL | extern "riscv-interrupt" fn isr() {}
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^ invalid ABI
| |
| invalid ABI
| help: did you mean: `"riscv-interrupt-m"`
| |
= note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions = 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() {}
| ++
error[E0703]: invalid ABI: found `riscv-interrupt-u` error[E0703]: invalid ABI: found `riscv-interrupt-u`
--> $DIR/riscv-discoverability-guidance.rs:22:8 --> $DIR/riscv-discoverability-guidance.rs:22:8
| |
LL | extern "riscv-interrupt-u" fn isr_U() {} LL | extern "riscv-interrupt-u" fn isr_U() {}
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^ invalid ABI
| |
| invalid ABI
| help: did you mean: `"riscv-interrupt-m"`
| |
= note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions = 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-u" fn isr_U() {}
LL + extern "riscv-interrupt-m" fn isr_U() {}
|
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -2,23 +2,26 @@ error[E0703]: invalid ABI: found `riscv-interrupt`
--> $DIR/riscv-discoverability-guidance.rs:17:8 --> $DIR/riscv-discoverability-guidance.rs:17:8
| |
LL | extern "riscv-interrupt" fn isr() {} LL | extern "riscv-interrupt" fn isr() {}
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^ invalid ABI
| |
| invalid ABI
| help: did you mean: `"riscv-interrupt-m"`
| |
= note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions = 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() {}
| ++
error[E0703]: invalid ABI: found `riscv-interrupt-u` error[E0703]: invalid ABI: found `riscv-interrupt-u`
--> $DIR/riscv-discoverability-guidance.rs:22:8 --> $DIR/riscv-discoverability-guidance.rs:22:8
| |
LL | extern "riscv-interrupt-u" fn isr_U() {} LL | extern "riscv-interrupt-u" fn isr_U() {}
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^ invalid ABI
| |
| invalid ABI
| help: did you mean: `"riscv-interrupt-m"`
| |
= note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions = 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-u" fn isr_U() {}
LL + extern "riscv-interrupt-m" fn isr_U() {}
|
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -2,12 +2,14 @@ error[E0703]: invalid ABI: found `cdedl`
--> $DIR/abi-typo.rs:2:8 --> $DIR/abi-typo.rs:2:8
| |
LL | extern "cdedl" fn cdedl() {} LL | extern "cdedl" fn cdedl() {}
| ^^^^^^^ | ^^^^^^^ invalid ABI
| |
| invalid ABI
| help: did you mean: `"cdecl"`
| |
= note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions
help: there's a similarly named valid ABI `cdecl`
|
LL - extern "cdedl" fn cdedl() {}
LL + extern "cdecl" fn cdedl() {}
|
error: aborting due to 1 previous error error: aborting due to 1 previous error