about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-07-03 17:26:56 +0200
committerGitHub <noreply@github.com>2024-07-03 17:26:56 +0200
commitce991da721e209751ecf510bd6264bf2a4ca595b (patch)
tree102efe5121ecb21128e8d0a23636e72e35926883
parent7fdb2f5cabeadb30cd84233fd4b69a61224237ac (diff)
parent8b6435d5ce4efaecca51e530f0cb3c44d527f3c4 (diff)
Rollup merge of #127248 - spastorino:unsafe-extern-tests, r=compiler-errors
Add parse fail test using safe trait/impl trait

Added 2 more tests to be sure that nothing weird happens using `safe` on items.
Needed to do this in separate tests as they give parsing errors.
-rw-r--r--tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.gated.stderr8
-rw-r--r--tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.rs8
-rw-r--r--tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.ungated.stderr8
-rw-r--r--tests/ui/rust-2024/unsafe-extern-blocks/safe-trait.gated.stderr8
-rw-r--r--tests/ui/rust-2024/unsafe-extern-blocks/safe-trait.rs7
-rw-r--r--tests/ui/rust-2024/unsafe-extern-blocks/safe-trait.ungated.stderr8
6 files changed, 47 insertions, 0 deletions
diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.gated.stderr b/tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.gated.stderr
new file mode 100644
index 00000000000..80e7a45f57e
--- /dev/null
+++ b/tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.gated.stderr
@@ -0,0 +1,8 @@
+error: expected one of `!` or `::`, found keyword `impl`
+  --> $DIR/safe-impl-trait.rs:5:6
+   |
+LL | safe impl Bar for () { }
+   |      ^^^^ expected one of `!` or `::`
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.rs b/tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.rs
new file mode 100644
index 00000000000..57c03e4d896
--- /dev/null
+++ b/tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.rs
@@ -0,0 +1,8 @@
+//@ revisions: gated ungated
+#![cfg_attr(gated, feature(unsafe_extern_blocks))]
+
+trait Bar {}
+safe impl Bar for () { }
+//~^ ERROR expected one of `!` or `::`, found keyword `impl`
+
+fn main() {}
diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.ungated.stderr b/tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.ungated.stderr
new file mode 100644
index 00000000000..80e7a45f57e
--- /dev/null
+++ b/tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.ungated.stderr
@@ -0,0 +1,8 @@
+error: expected one of `!` or `::`, found keyword `impl`
+  --> $DIR/safe-impl-trait.rs:5:6
+   |
+LL | safe impl Bar for () { }
+   |      ^^^^ expected one of `!` or `::`
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/safe-trait.gated.stderr b/tests/ui/rust-2024/unsafe-extern-blocks/safe-trait.gated.stderr
new file mode 100644
index 00000000000..de84037f28c
--- /dev/null
+++ b/tests/ui/rust-2024/unsafe-extern-blocks/safe-trait.gated.stderr
@@ -0,0 +1,8 @@
+error: expected one of `!` or `::`, found keyword `trait`
+  --> $DIR/safe-trait.rs:4:6
+   |
+LL | safe trait Foo {}
+   |      ^^^^^ expected one of `!` or `::`
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/safe-trait.rs b/tests/ui/rust-2024/unsafe-extern-blocks/safe-trait.rs
new file mode 100644
index 00000000000..e73cb45b188
--- /dev/null
+++ b/tests/ui/rust-2024/unsafe-extern-blocks/safe-trait.rs
@@ -0,0 +1,7 @@
+//@ revisions: gated ungated
+#![cfg_attr(gated, feature(unsafe_extern_blocks))]
+
+safe trait Foo {}
+//~^ ERROR expected one of `!` or `::`, found keyword `trait`
+
+fn main() {}
diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/safe-trait.ungated.stderr b/tests/ui/rust-2024/unsafe-extern-blocks/safe-trait.ungated.stderr
new file mode 100644
index 00000000000..de84037f28c
--- /dev/null
+++ b/tests/ui/rust-2024/unsafe-extern-blocks/safe-trait.ungated.stderr
@@ -0,0 +1,8 @@
+error: expected one of `!` or `::`, found keyword `trait`
+  --> $DIR/safe-trait.rs:4:6
+   |
+LL | safe trait Foo {}
+   |      ^^^^^ expected one of `!` or `::`
+
+error: aborting due to 1 previous error
+