From ac2e3180344bdd6092fe2b845df65c4ff4a5aa10 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 26 Sep 2024 20:16:40 +0200 Subject: [PATCH] make type-check-4 asm tests about non-const expressions --- tests/ui/asm/aarch64/type-check-4.rs | 27 ------------------------ tests/ui/asm/aarch64/type-check-4.stderr | 21 ------------------ tests/ui/asm/non-const.rs | 11 ++++++++++ tests/ui/asm/non-const.stderr | 11 ++++++++++ tests/ui/asm/x86_64/type-check-4.rs | 27 ------------------------ tests/ui/asm/x86_64/type-check-4.stderr | 21 ------------------ 6 files changed, 22 insertions(+), 96 deletions(-) delete mode 100644 tests/ui/asm/aarch64/type-check-4.rs delete mode 100644 tests/ui/asm/aarch64/type-check-4.stderr create mode 100644 tests/ui/asm/non-const.rs create mode 100644 tests/ui/asm/non-const.stderr delete mode 100644 tests/ui/asm/x86_64/type-check-4.rs delete mode 100644 tests/ui/asm/x86_64/type-check-4.stderr diff --git a/tests/ui/asm/aarch64/type-check-4.rs b/tests/ui/asm/aarch64/type-check-4.rs deleted file mode 100644 index c24567bd5b002..0000000000000 --- a/tests/ui/asm/aarch64/type-check-4.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ only-aarch64 -//@ build-fail - -use std::arch::global_asm; - -fn main() {} - -// Constants must be... constant - -static mut S: i32 = 1; -const fn const_foo(x: i32) -> i32 { - x -} -const fn const_bar(x: T) -> T { - x -} -global_asm!("{}", const unsafe { S }); -//~^ ERROR: evaluation of constant value failed -//~| mutable global memory -global_asm!("{}", const const_foo(0)); -global_asm!("{}", const const_foo(unsafe { S })); -//~^ ERROR: evaluation of constant value failed -//~| mutable global memory -global_asm!("{}", const const_bar(0)); -global_asm!("{}", const const_bar(unsafe { S })); -//~^ ERROR: evaluation of constant value failed -//~| mutable global memory diff --git a/tests/ui/asm/aarch64/type-check-4.stderr b/tests/ui/asm/aarch64/type-check-4.stderr deleted file mode 100644 index 8c22dfcdb5ed6..0000000000000 --- a/tests/ui/asm/aarch64/type-check-4.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/type-check-4.rs:17:34 - | -LL | global_asm!("{}", const unsafe { S }); - | ^ constant accesses mutable global memory - -error[E0080]: evaluation of constant value failed - --> $DIR/type-check-4.rs:21:44 - | -LL | global_asm!("{}", const const_foo(unsafe { S })); - | ^ constant accesses mutable global memory - -error[E0080]: evaluation of constant value failed - --> $DIR/type-check-4.rs:25:44 - | -LL | global_asm!("{}", const const_bar(unsafe { S })); - | ^ constant accesses mutable global memory - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/asm/non-const.rs b/tests/ui/asm/non-const.rs new file mode 100644 index 0000000000000..63c4656322610 --- /dev/null +++ b/tests/ui/asm/non-const.rs @@ -0,0 +1,11 @@ +//@ needs-asm-support + +use std::arch::global_asm; + +fn main() {} + +// Constants must be... constant +fn non_const_fn(x: i32) -> i32 { x } + +global_asm!("/* {} */", const non_const_fn(0)); +//~^ERROR: cannot call non-const fn diff --git a/tests/ui/asm/non-const.stderr b/tests/ui/asm/non-const.stderr new file mode 100644 index 0000000000000..5fae2ac984378 --- /dev/null +++ b/tests/ui/asm/non-const.stderr @@ -0,0 +1,11 @@ +error[E0015]: cannot call non-const fn `non_const_fn` in constants + --> $DIR/non-const.rs:10:31 + | +LL | global_asm!("/* {} */", const non_const_fn(0)); + | ^^^^^^^^^^^^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/asm/x86_64/type-check-4.rs b/tests/ui/asm/x86_64/type-check-4.rs deleted file mode 100644 index ebc6edc07e4cd..0000000000000 --- a/tests/ui/asm/x86_64/type-check-4.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ only-x86_64 -//@ build-fail - -use std::arch::global_asm; - -fn main() {} - -// Constants must be... constant - -static mut S: i32 = 1; -const fn const_foo(x: i32) -> i32 { - x -} -const fn const_bar(x: T) -> T { - x -} -global_asm!("{}", const unsafe { S }); -//~^ ERROR evaluation of constant value failed -//~| mutable global memory -global_asm!("{}", const const_foo(0)); -global_asm!("{}", const const_foo(unsafe { S })); -//~^ ERROR evaluation of constant value failed -//~| mutable global memory -global_asm!("{}", const const_bar(0)); -global_asm!("{}", const const_bar(unsafe { S })); -//~^ ERROR evaluation of constant value failed -//~| mutable global memory diff --git a/tests/ui/asm/x86_64/type-check-4.stderr b/tests/ui/asm/x86_64/type-check-4.stderr deleted file mode 100644 index 8c22dfcdb5ed6..0000000000000 --- a/tests/ui/asm/x86_64/type-check-4.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/type-check-4.rs:17:34 - | -LL | global_asm!("{}", const unsafe { S }); - | ^ constant accesses mutable global memory - -error[E0080]: evaluation of constant value failed - --> $DIR/type-check-4.rs:21:44 - | -LL | global_asm!("{}", const const_foo(unsafe { S })); - | ^ constant accesses mutable global memory - -error[E0080]: evaluation of constant value failed - --> $DIR/type-check-4.rs:25:44 - | -LL | global_asm!("{}", const const_bar(unsafe { S })); - | ^ constant accesses mutable global memory - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0080`.