diff options
| author | Michael Goulet <michael@errs.io> | 2025-02-17 16:09:46 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2025-02-22 00:12:07 +0000 |
| commit | 6ba39f7dc709a90bcb125974964a7e464ed86ff2 (patch) | |
| tree | 68d6c9515988454516ca2373683f87d01b890c9f /tests/ui/asm | |
| parent | 37060aae13d0fe771f9d3222f1c644820a9d2837 (diff) | |
| download | rust-6ba39f7dc709a90bcb125974964a7e464ed86ff2.tar.gz rust-6ba39f7dc709a90bcb125974964a7e464ed86ff2.zip | |
Make a fake body to store typeck results for global_asm
Diffstat (limited to 'tests/ui/asm')
| -rw-r--r-- | tests/ui/asm/asm-with-nested-closure.rs | 11 | ||||
| -rw-r--r-- | tests/ui/asm/global-asm-with-lifetimes.rs | 8 | ||||
| -rw-r--r-- | tests/ui/asm/inline-asm-with-lifetimes.bad.stderr | 17 | ||||
| -rw-r--r-- | tests/ui/asm/inline-asm-with-lifetimes.rs | 22 |
4 files changed, 58 insertions, 0 deletions
diff --git a/tests/ui/asm/asm-with-nested-closure.rs b/tests/ui/asm/asm-with-nested-closure.rs new file mode 100644 index 00000000000..3a5cd48d5d4 --- /dev/null +++ b/tests/ui/asm/asm-with-nested-closure.rs @@ -0,0 +1,11 @@ +//@ build-pass +//@ needs-asm-support + +fn foo<const N: usize>() {} + +core::arch::global_asm!("/* {} */", sym foo::<{ + || {}; + 0 +}>); + +fn main() {} diff --git a/tests/ui/asm/global-asm-with-lifetimes.rs b/tests/ui/asm/global-asm-with-lifetimes.rs new file mode 100644 index 00000000000..2709ff90fe3 --- /dev/null +++ b/tests/ui/asm/global-asm-with-lifetimes.rs @@ -0,0 +1,8 @@ +//@ build-pass +//@ needs-asm-support + +fn foo<T>() {} + +core::arch::global_asm!("/* {} */", sym foo::<&'static ()>); + +fn main() {} diff --git a/tests/ui/asm/inline-asm-with-lifetimes.bad.stderr b/tests/ui/asm/inline-asm-with-lifetimes.bad.stderr new file mode 100644 index 00000000000..f04482f9c59 --- /dev/null +++ b/tests/ui/asm/inline-asm-with-lifetimes.bad.stderr @@ -0,0 +1,17 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/inline-asm-with-lifetimes.rs:17:26 + | +LL | fn test<'a: 'a, T>() { + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... +LL | unsafe { +LL | asm!("/* {} */", sym dep::<'a, T> ); + | ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound + | +LL | fn test<'a: 'a, T: 'a>() { + | ++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0309`. diff --git a/tests/ui/asm/inline-asm-with-lifetimes.rs b/tests/ui/asm/inline-asm-with-lifetimes.rs new file mode 100644 index 00000000000..79def03eeb2 --- /dev/null +++ b/tests/ui/asm/inline-asm-with-lifetimes.rs @@ -0,0 +1,22 @@ +//@ revisions: good bad +//@[good] build-pass +//@ needs-asm-support + +use std::arch::asm; + +// lifetime requirement, we should check it!! +#[cfg(bad)] +fn dep<'a, T: 'a>() {} + +// no lifetime requirement +#[cfg(good)] +fn dep<'a: 'a, T>() {} + +fn test<'a: 'a, T>() { + unsafe { + asm!("/* {} */", sym dep::<'a, T> ); + //[bad]~^ ERROR the parameter type `T` may not live long enough + } +} + +fn main() {} |
