improve error message when global_asm! uses asm! options#128207
Merged
bors merged 5 commits intorust-lang:masterfrom Jul 27, 2024
Merged
improve error message when global_asm! uses asm! options#128207bors merged 5 commits intorust-lang:masterfrom
global_asm! uses asm! options#128207bors merged 5 commits intorust-lang:masterfrom
Conversation
Collaborator
Member
|
r? @Amanieu |
tgross35
reviewed
Jul 25, 2024
tgross35
reviewed
Jul 25, 2024
Member
|
@bors r+ |
Collaborator
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Jul 27, 2024
…r=Amanieu
improve error message when `global_asm!` uses `asm!` options
specifically, what was
error: expected one of `)`, `att_syntax`, or `raw`, found `preserves_flags`
--> $DIR/bad-options.rs:45:25
|
LL | global_asm!("", options(preserves_flags));
| ^^^^^^^^^^^^^^^ expected one of `)`, `att_syntax`, or `raw`
is now
error: the `preserves_flags` option cannot be used with `global_asm!`
--> $DIR/bad-options.rs:45:25
|
LL | global_asm!("", options(preserves_flags));
| ^^^^^^^^^^^^^^^ the `preserves_flags` option is not meaningful for global-scoped inline assembly
mirroring the phrasing of the [reference](https://doc.rust-lang.org/reference/inline-assembly.html#options).
This is also a bit of a refactor for a future `naked_asm!` macro (for use in `#[naked]` functions). Currently this sort of error can come up when switching from inline to global asm, or when a user just isn't that experienced with assembly. With `naked_asm!` added to the mix hitting this error is more likely.
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jul 27, 2024
…iaskrgr Rollup of 3 pull requests Successful merges: - rust-lang#128006 (Make `missing_fragment_specifier` an error in edition 2024) - rust-lang#128207 (improve error message when `global_asm!` uses `asm!` options) - rust-lang#128266 (update `rust.channel` default value documentation) r? `@ghost` `@rustbot` modify labels: rollup
Member
Contributor
Author
|
so CI fails on some of the aarch64 tests. I'm on x86, so how am I supposed to update those? for some using |
Member
|
You can run the UI tests with a cross-compiler by running |
Amanieu
reviewed
Jul 27, 2024
| @@ -0,0 +1,10 @@ | |||
| //@ run-rustfix | |||
Member
There was a problem hiding this comment.
This probably needs //@ needs-asm-support otherwise it will fail on targets without asm support.
Member
|
@bors r+ |
Collaborator
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jul 27, 2024
Rollup of 8 pull requests Successful merges: - rust-lang#125897 (from_ref, from_mut: clarify documentation) - rust-lang#128207 (improve error message when `global_asm!` uses `asm!` options) - rust-lang#128241 (Remove logic to suggest clone of function output) - rust-lang#128259 ([illumos/solaris] set MSG_NOSIGNAL while writing to sockets) - rust-lang#128262 (Delete `SimplifyArmIdentity` and `SimplifyBranchSame` tests) - rust-lang#128266 (update `rust.channel` default value documentation) - rust-lang#128267 (Add rustdoc GUI test to check title with and without search) - rust-lang#128271 (Disable jump threading of float equality) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jul 27, 2024
Rollup merge of rust-lang#128207 - folkertdev:asm-parser-generalize, r=Amanieu improve error message when `global_asm!` uses `asm!` options specifically, what was error: expected one of `)`, `att_syntax`, or `raw`, found `preserves_flags` --> $DIR/bad-options.rs:45:25 | LL | global_asm!("", options(preserves_flags)); | ^^^^^^^^^^^^^^^ expected one of `)`, `att_syntax`, or `raw` is now error: the `preserves_flags` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:45:25 | LL | global_asm!("", options(preserves_flags)); | ^^^^^^^^^^^^^^^ the `preserves_flags` option is not meaningful for global-scoped inline assembly mirroring the phrasing of the [reference](https://doc.rust-lang.org/reference/inline-assembly.html#options). This is also a bit of a refactor for a future `naked_asm!` macro (for use in `#[naked]` functions). Currently this sort of error can come up when switching from inline to global asm, or when a user just isn't that experienced with assembly. With `naked_asm!` added to the mix hitting this error is more likely.
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Aug 4, 2024
…operand, r=Amanieu improve error message when `global_asm!` uses `asm!` operands follow-up to rust-lang#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.
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Aug 4, 2024
…operand, r=Amanieu improve error message when `global_asm!` uses `asm!` operands follow-up to rust-lang#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.
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Aug 4, 2024
Rollup merge of rust-lang#128305 - folkertdev:asm-parser-unsupported-operand, r=Amanieu improve error message when `global_asm!` uses `asm!` operands follow-up to rust-lang#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.
RalfJung
pushed a commit
to RalfJung/miri
that referenced
this pull request
Aug 5, 2024
…r=Amanieu improve error message when `global_asm!` uses `asm!` operands follow-up to rust-lang/rust#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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
specifically, what was
is now
mirroring the phrasing of the reference.
This is also a bit of a refactor for a future
naked_asm!macro (for use in#[naked]functions). Currently this sort of error can come up when switching from inline to global asm, or when a user just isn't that experienced with assembly. Withnaked_asm!added to the mix hitting this error is more likely.