From edf32cf50298f0bfb7e294699998a667304e7ad1 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 20 Jun 2024 16:29:59 -0300 Subject: [PATCH] Test that safe items fail even with feature(unsafe_extern_blocks) --- .../rust-2024/safe-outside-extern-with-feature.rs | 9 +++++++++ .../safe-outside-extern-with-feature.stderr | 14 ++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/ui/rust-2024/safe-outside-extern-with-feature.rs create mode 100644 tests/ui/rust-2024/safe-outside-extern-with-feature.stderr diff --git a/tests/ui/rust-2024/safe-outside-extern-with-feature.rs b/tests/ui/rust-2024/safe-outside-extern-with-feature.rs new file mode 100644 index 0000000000000..b743cde2b86ad --- /dev/null +++ b/tests/ui/rust-2024/safe-outside-extern-with-feature.rs @@ -0,0 +1,9 @@ +#![feature(unsafe_extern_blocks)] + +safe fn foo() {} +//~^ ERROR: items cannot be declared with `safe` safety qualifier + +safe static FOO: i32 = 1; +//~^ ERROR: items cannot be declared with `safe` safety qualifier + +fn main() {} diff --git a/tests/ui/rust-2024/safe-outside-extern-with-feature.stderr b/tests/ui/rust-2024/safe-outside-extern-with-feature.stderr new file mode 100644 index 0000000000000..02108b28d2b96 --- /dev/null +++ b/tests/ui/rust-2024/safe-outside-extern-with-feature.stderr @@ -0,0 +1,14 @@ +error: items cannot be declared with `safe` safety qualifier + --> $DIR/safe-outside-extern-with-feature.rs:3:1 + | +LL | safe fn foo() {} + | ^^^^^^^^^^^^^^^^ + +error: items cannot be declared with `safe` safety qualifier + --> $DIR/safe-outside-extern-with-feature.rs:6:1 + | +LL | safe static FOO: i32 = 1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors +