-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Permit asm_const
and asm_sym
to reference generic params
#96800
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
cf5748f
Make `AnonConst` in asm_consts generic
nbdd0121 d93b037
Remove wfness requirement from anon consts used by asm
nbdd0121 b1c6c06
Permit asm_const and asm_sym to reference outer generic params
nbdd0121 441d98f
Expand feature gate testing for asm_const/asm_sym
nbdd0121 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 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 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 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 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 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 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,30 @@ | ||
// needs-asm-support | ||
// build-pass | ||
|
||
#![feature(asm_const, asm_sym)] | ||
|
||
use std::arch::asm; | ||
|
||
fn foofoo<const N: usize>() {} | ||
|
||
unsafe fn foo<const N: usize>() { | ||
asm!("/* {0} */", const N); | ||
asm!("/* {0} */", const N + 1); | ||
asm!("/* {0} */", sym foofoo::<N>); | ||
} | ||
|
||
fn barbar<T>() {} | ||
|
||
unsafe fn bar<T>() { | ||
asm!("/* {0} */", const std::mem::size_of::<T>()); | ||
asm!("/* {0} */", const std::mem::size_of::<(T, T)>()); | ||
asm!("/* {0} */", sym barbar::<T>); | ||
asm!("/* {0} */", sym barbar::<(T, T)>); | ||
} | ||
|
||
fn main() { | ||
unsafe { | ||
foo::<0>(); | ||
bar::<usize>(); | ||
} | ||
} |
This file contains 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 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 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 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 |
---|---|---|
@@ -1,12 +1,21 @@ | ||
error[E0658]: const operands for inline assembly are unstable | ||
--> $DIR/feature-gate-asm_const.rs:7:29 | ||
--> $DIR/feature-gate-asm_const.rs:6:25 | ||
| | ||
LL | asm!("mov eax, {}", const N + 1); | ||
| ^^^^^^^^^^^ | ||
| | ||
= note: see issue #93332 <https://github.com/rust-lang/rust/issues/93332> for more information | ||
= help: add `#![feature(asm_const)]` to the crate attributes to enable | ||
|
||
error[E0658]: const operands for inline assembly are unstable | ||
--> $DIR/feature-gate-asm_const.rs:13:29 | ||
| | ||
LL | asm!("mov eax, {}", const 123); | ||
| ^^^^^^^^^ | ||
| | ||
= note: see issue #93332 <https://github.com/rust-lang/rust/issues/93332> for more information | ||
= help: add `#![feature(asm_const)]` to the crate attributes to enable | ||
|
||
error: aborting due to previous error | ||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
This file contains 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 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 |
---|---|---|
@@ -1,12 +1,21 @@ | ||
error[E0658]: sym operands for inline assembly are unstable | ||
--> $DIR/feature-gate-asm_sym.rs:7:29 | ||
--> $DIR/feature-gate-asm_sym.rs:9:29 | ||
| | ||
LL | asm!("mov eax, {}", sym main); | ||
| ^^^^^^^^ | ||
LL | asm!("mov eax, {}", sym bar::<N>); | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: see issue #93333 <https://github.com/rust-lang/rust/issues/93333> for more information | ||
= help: add `#![feature(asm_sym)]` to the crate attributes to enable | ||
|
||
error: aborting due to previous error | ||
error[E0658]: sym operands for inline assembly are unstable | ||
--> $DIR/feature-gate-asm_sym.rs:16:29 | ||
| | ||
LL | asm!("mov eax, {}", sym foo::<0>); | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: see issue #93333 <https://github.com/rust-lang/rust/issues/93333> for more information | ||
= help: add `#![feature(asm_sym)]` to the crate attributes to enable | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
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.
We are missing a feature gate test for these constructs with generics I think.