-
Notifications
You must be signed in to change notification settings - Fork 13.3k
builtin_macros: Fix use of interpolated identifiers in asm!
#77595
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// only-x86_64 | ||
|
||
#![feature(asm)] | ||
|
||
macro_rules! m { | ||
($in:ident $out:ident $lateout:ident $inout:ident $inlateout:ident $const:ident $sym:ident | ||
$pure:ident $nomem:ident $readonly:ident $preserves_flags:ident | ||
$noreturn:ident $nostack:ident $att_syntax:ident $options:ident) => { | ||
unsafe { | ||
asm!("", $in(x) x, $out(x) x, $lateout(x) x, $inout(x) x, $inlateout(x) x, | ||
//~^ ERROR asm outputs are not allowed with the `noreturn` option | ||
const x, sym x, | ||
$options($pure, $nomem, $readonly, $preserves_flags, $noreturn, $nostack, $att_syntax)); | ||
//~^ ERROR the `nomem` and `readonly` options are mutually exclusive | ||
//~| ERROR the `pure` and `noreturn` options are mutually exclusive | ||
} | ||
}; | ||
} | ||
|
||
fn main() { | ||
m!(in out lateout inout inlateout const sym | ||
pure nomem readonly preserves_flags | ||
noreturn nostack att_syntax options); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
error: the `nomem` and `readonly` options are mutually exclusive | ||
--> $DIR/interpolated-idents.rs:13:13 | ||
| | ||
LL | $options($pure, $nomem, $readonly, $preserves_flags, $noreturn, $nostack, $att_syntax)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
... | ||
LL | / m!(in out lateout inout inlateout const sym | ||
LL | | pure nomem readonly preserves_flags | ||
LL | | noreturn nostack att_syntax options); | ||
| |____________________________________________- in this macro invocation | ||
| | ||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: the `pure` and `noreturn` options are mutually exclusive | ||
--> $DIR/interpolated-idents.rs:13:13 | ||
| | ||
LL | $options($pure, $nomem, $readonly, $preserves_flags, $noreturn, $nostack, $att_syntax)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
... | ||
LL | / m!(in out lateout inout inlateout const sym | ||
LL | | pure nomem readonly preserves_flags | ||
LL | | noreturn nostack att_syntax options); | ||
| |____________________________________________- in this macro invocation | ||
| | ||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: asm outputs are not allowed with the `noreturn` option | ||
--> $DIR/interpolated-idents.rs:10:32 | ||
| | ||
LL | asm!("", $in(x) x, $out(x) x, $lateout(x) x, $inout(x) x, $inlateout(x) x, | ||
| ^^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^^^^ | ||
... | ||
LL | m!(in out lateout inout inlateout const sym | ||
| _____- | ||
| |_____| | ||
| |_____| | ||
| |_____| | ||
| | | ||
LL | | pure nomem readonly preserves_flags | ||
LL | | noreturn nostack att_syntax options); | ||
| | - | ||
| |____________________________________________| | ||
| |____________________________________________in this macro invocation | ||
| |____________________________________________in this macro invocation | ||
| |____________________________________________in this macro invocation | ||
| in this macro invocation | ||
| | ||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to 3 previous errors | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh wow... cc @rust-lang/wg-diagnostics we should probably deduplicate
span_label
s that have the same message and spanThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we do this already, but it's intentionally disabled for UI tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Aaron1011
No, with
-Z deduplicate-diagnostics=yes
the output looks the same.Full diagnostics (error + all the attached notes and labels) are deduplicated, not individual fragments.