diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-08-04 11:32:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-04 11:32:33 +0200 |
| commit | b6b8330b9dbffbf109e9b9fea0dd6ad5acd22a16 (patch) | |
| tree | 1de6559c649171b786f13062de1d70c0d8416f0a /compiler/rustc_builtin_macros/messages.ftl | |
| parent | b389b0ab72cb0aa9acf4df0ae0c0e12090782da9 (diff) | |
| parent | 571f7b658964e5781546e8ea4a2d1466e8b0a611 (diff) | |
| download | rust-b6b8330b9dbffbf109e9b9fea0dd6ad5acd22a16.tar.gz rust-b6b8330b9dbffbf109e9b9fea0dd6ad5acd22a16.zip | |
Rollup merge of #128305 - folkertdev:asm-parser-unsupported-operand, r=Amanieu
improve error message when `global_asm!` uses `asm!` operands
follow-up to https://github.com/rust-lang/rust/pull/128207
what was
```
error: expected expression, found keyword `in`
--> src/lib.rs:1:31
|
1 | core::arch::global_asm!("{}", in(reg));
| ^^ expected expression
```
becomes
```
error: the `in` operand cannot be used with `global_asm!`
--> $DIR/parse-error.rs:150:19
|
LL | global_asm!("{}", in(reg));
| ^^ the `in` operand is not meaningful for global-scoped inline assembly, remove it
```
the span of the error is just the keyword, which means that we can't create a machine-applicable suggestion here. The alternative would be to attempt to parse the full operand, but then if there are syntax errors in the operand those would be presented to the user, even though the parser already knows that the output won't be valid. Also that would require more complexity in the parser.
So I think this is a nice improvement at very low cost.
Diffstat (limited to 'compiler/rustc_builtin_macros/messages.ftl')
| -rw-r--r-- | compiler/rustc_builtin_macros/messages.ftl | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/rustc_builtin_macros/messages.ftl b/compiler/rustc_builtin_macros/messages.ftl index ae3cce40f5d..9695df9c87e 100644 --- a/compiler/rustc_builtin_macros/messages.ftl +++ b/compiler/rustc_builtin_macros/messages.ftl @@ -196,6 +196,9 @@ builtin_macros_format_use_positional = consider using a positional formatting ar builtin_macros_global_asm_clobber_abi = `clobber_abi` cannot be used with `global_asm!` +builtin_macros_global_asm_unsupported_operand = the `{$symbol}` operand cannot be used with `global_asm!` + .label = the `{$symbol}` operand is not meaningful for global-scoped inline assembly, remove it + builtin_macros_global_asm_unsupported_option = the `{$symbol}` option cannot be used with `global_asm!` .label = the `{$symbol}` option is not meaningful for global-scoped inline assembly .suggestion = remove this option |
