diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2025-02-28 03:35:13 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2025-02-28 03:35:13 +0000 |
| commit | 86945c0a545643457e551a78e8c2a90355d0f17c (patch) | |
| tree | a52ec432a83e44ea8f6930417cf9629e3913269c /compiler | |
| parent | f45d4acf1bb635aa010f19f8a749eed8293203b3 (diff) | |
| download | rust-86945c0a545643457e551a78e8c2a90355d0f17c.tar.gz rust-86945c0a545643457e551a78e8c2a90355d0f17c.zip | |
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() {}
| ++
```
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_ast_lowering/messages.ftl | 2 | ||||
| -rw-r--r-- | compiler/rustc_ast_lowering/src/errors.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_ast_lowering/src/item.rs | 2 |
3 files changed, 5 insertions, 4 deletions
diff --git a/compiler/rustc_ast_lowering/messages.ftl b/compiler/rustc_ast_lowering/messages.ftl index 1b91c33742d..f29c98164d0 100644 --- a/compiler/rustc_ast_lowering/messages.ftl +++ b/compiler/rustc_ast_lowering/messages.ftl @@ -88,7 +88,7 @@ ast_lowering_invalid_abi_clobber_abi = invalid ABI for `clobber_abi` .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 = asm template modifiers are not allowed for `const` arguments diff --git a/compiler/rustc_ast_lowering/src/errors.rs b/compiler/rustc_ast_lowering/src/errors.rs index f31e2db051d..766c0233408 100644 --- a/compiler/rustc_ast_lowering/src/errors.rs +++ b/compiler/rustc_ast_lowering/src/errors.rs @@ -46,8 +46,9 @@ pub(crate) struct TupleStructWithDefault { #[derive(Subdiagnostic)] #[suggestion( ast_lowering_invalid_abi_suggestion, - code = "{suggestion}", - applicability = "maybe-incorrect" + code = "\"{suggestion}\"", + applicability = "maybe-incorrect", + style = "verbose" )] pub(crate) struct InvalidAbiSuggestion { #[primary_span] diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index a4fc4b3e3a1..15802101f71 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1510,7 +1510,7 @@ impl<'hir> LoweringContext<'_, 'hir> { span: abi.span, suggestion: suggested_name.map(|suggested_name| InvalidAbiSuggestion { span: abi.span, - suggestion: format!("\"{suggested_name}\""), + suggestion: suggested_name.to_string(), }), command: "rustc --print=calling-conventions".to_string(), }); |
