Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak incorrect ABI suggestion and make suggestion verbose #137771

Merged
merged 1 commit into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_ast_lowering/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});
Expand Down
19 changes: 11 additions & 8 deletions tests/ui/abi/riscv-discoverability-guidance.riscv32.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@ error[E0703]: invalid ABI: found `riscv-interrupt`
--> $DIR/riscv-discoverability-guidance.rs:17:8
|
LL | extern "riscv-interrupt" fn isr() {}
| ^^^^^^^^^^^^^^^^^
| |
| invalid ABI
| help: did you mean: `"riscv-interrupt-m"`
| ^^^^^^^^^^^^^^^^^ 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() {}
| ++

error[E0703]: invalid ABI: found `riscv-interrupt-u`
--> $DIR/riscv-discoverability-guidance.rs:22:8
|
LL | extern "riscv-interrupt-u" fn isr_U() {}
| ^^^^^^^^^^^^^^^^^^^
| |
| invalid ABI
| help: did you mean: `"riscv-interrupt-m"`
| ^^^^^^^^^^^^^^^^^^^ 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-u" fn isr_U() {}
LL + extern "riscv-interrupt-m" fn isr_U() {}
|

error: aborting due to 2 previous errors

Expand Down
19 changes: 11 additions & 8 deletions tests/ui/abi/riscv-discoverability-guidance.riscv64.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@ error[E0703]: invalid ABI: found `riscv-interrupt`
--> $DIR/riscv-discoverability-guidance.rs:17:8
|
LL | extern "riscv-interrupt" fn isr() {}
| ^^^^^^^^^^^^^^^^^
| |
| invalid ABI
| help: did you mean: `"riscv-interrupt-m"`
| ^^^^^^^^^^^^^^^^^ 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() {}
| ++

error[E0703]: invalid ABI: found `riscv-interrupt-u`
--> $DIR/riscv-discoverability-guidance.rs:22:8
|
LL | extern "riscv-interrupt-u" fn isr_U() {}
| ^^^^^^^^^^^^^^^^^^^
| |
| invalid ABI
| help: did you mean: `"riscv-interrupt-m"`
| ^^^^^^^^^^^^^^^^^^^ 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-u" fn isr_U() {}
LL + extern "riscv-interrupt-m" fn isr_U() {}
|

error: aborting due to 2 previous errors

Expand Down
10 changes: 6 additions & 4 deletions tests/ui/suggestions/abi-typo.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ error[E0703]: invalid ABI: found `cdedl`
--> $DIR/abi-typo.rs:2:8
|
LL | extern "cdedl" fn cdedl() {}
| ^^^^^^^
| |
| invalid ABI
| help: did you mean: `"cdecl"`
| ^^^^^^^ invalid ABI
|
= 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

Expand Down
Loading