about summary refs log tree commit diff
diff options
context:
space:
mode:
authorcarbotaniuman <41451839+carbotaniuman@users.noreply.github.com>2024-05-16 02:08:26 -0500
committercarbotaniuman <41451839+carbotaniuman@users.noreply.github.com>2024-06-06 20:27:25 -0500
commitb82c5249961a6bd3ecacb98c68f9090892ec2615 (patch)
tree4f0c68920c0b457b18d2655fd9cf1db8d3605176
parent68719e0bda178103a3e4af0dc1e7df45f1d9dd00 (diff)
downloadrust-b82c5249961a6bd3ecacb98c68f9090892ec2615.tar.gz
rust-b82c5249961a6bd3ecacb98c68f9090892ec2615.zip
Add double unsafe test
-rw-r--r--tests/ui/attributes/unsafe/double-unsafe-attributes.rs9
-rw-r--r--tests/ui/attributes/unsafe/double-unsafe-attributes.stderr27
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/ui/attributes/unsafe/double-unsafe-attributes.rs b/tests/ui/attributes/unsafe/double-unsafe-attributes.rs
new file mode 100644
index 00000000000..a6c0ea578f2
--- /dev/null
+++ b/tests/ui/attributes/unsafe/double-unsafe-attributes.rs
@@ -0,0 +1,9 @@
+#![feature(unsafe_attributes)]
+
+#[unsafe(unsafe(no_mangle))]
+//~^ ERROR expected identifier, found keyword `unsafe`
+//~| ERROR cannot find attribute `r#unsafe` in this scope
+//~| ERROR `r#unsafe` is not an unsafe attribute
+fn a() {}
+
+fn main() {}
diff --git a/tests/ui/attributes/unsafe/double-unsafe-attributes.stderr b/tests/ui/attributes/unsafe/double-unsafe-attributes.stderr
new file mode 100644
index 00000000000..1c07a5bf8ba
--- /dev/null
+++ b/tests/ui/attributes/unsafe/double-unsafe-attributes.stderr
@@ -0,0 +1,27 @@
+error: expected identifier, found keyword `unsafe`
+  --> $DIR/double-unsafe-attributes.rs:3:10
+   |
+LL | #[unsafe(unsafe(no_mangle))]
+   |          ^^^^^^ expected identifier, found keyword
+   |
+help: escape `unsafe` to use it as an identifier
+   |
+LL | #[unsafe(r#unsafe(no_mangle))]
+   |          ++
+
+error: cannot find attribute `r#unsafe` in this scope
+  --> $DIR/double-unsafe-attributes.rs:3:10
+   |
+LL | #[unsafe(unsafe(no_mangle))]
+   |          ^^^^^^
+
+error: `r#unsafe` is not an unsafe attribute
+  --> $DIR/double-unsafe-attributes.rs:3:3
+   |
+LL | #[unsafe(unsafe(no_mangle))]
+   |   ^^^^^^
+   |
+   = note: extraneous unsafe is not allowed in attributes
+
+error: aborting due to 3 previous errors
+