about summary refs log tree commit diff
path: root/tests/ui/lint/unsafe_code
diff options
context:
space:
mode:
authorSantiago Pastorino <spastorino@gmail.com>2024-07-09 17:35:51 -0300
committerSantiago Pastorino <spastorino@gmail.com>2024-07-09 17:35:51 -0300
commita3ef94e80e0ec7bacd42a70bd8a2203c5cc3fab8 (patch)
tree521677f779398a1967d1b842f56f8379a8f9a82d /tests/ui/lint/unsafe_code
parentc3774be7411722d3695de2ab1da9a358d0d5c82c (diff)
downloadrust-a3ef94e80e0ec7bacd42a70bd8a2203c5cc3fab8.tar.gz
rust-a3ef94e80e0ec7bacd42a70bd8a2203c5cc3fab8.zip
Fire unsafe_code lint on unsafe extern blocks
Diffstat (limited to 'tests/ui/lint/unsafe_code')
-rw-r--r--tests/ui/lint/unsafe_code/unsafe-extern-blocks.rs14
-rw-r--r--tests/ui/lint/unsafe_code/unsafe-extern-blocks.stderr17
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/ui/lint/unsafe_code/unsafe-extern-blocks.rs b/tests/ui/lint/unsafe_code/unsafe-extern-blocks.rs
new file mode 100644
index 00000000000..6f2ead70db8
--- /dev/null
+++ b/tests/ui/lint/unsafe_code/unsafe-extern-blocks.rs
@@ -0,0 +1,14 @@
+#![feature(unsafe_extern_blocks)]
+#![deny(unsafe_code)]
+
+#[allow(unsafe_code)]
+unsafe extern "C" {
+    fn foo();
+}
+
+unsafe extern "C" {
+    //~^ ERROR usage of an `unsafe extern` block [unsafe_code]
+    fn bar();
+}
+
+fn main() {}
diff --git a/tests/ui/lint/unsafe_code/unsafe-extern-blocks.stderr b/tests/ui/lint/unsafe_code/unsafe-extern-blocks.stderr
new file mode 100644
index 00000000000..5439a311256
--- /dev/null
+++ b/tests/ui/lint/unsafe_code/unsafe-extern-blocks.stderr
@@ -0,0 +1,17 @@
+error: usage of an `unsafe extern` block
+  --> $DIR/unsafe-extern-blocks.rs:9:1
+   |
+LL | / unsafe extern "C" {
+LL | |
+LL | |     fn bar();
+LL | | }
+   | |_^
+   |
+note: the lint level is defined here
+  --> $DIR/unsafe-extern-blocks.rs:2:9
+   |
+LL | #![deny(unsafe_code)]
+   |         ^^^^^^^^^^^
+
+error: aborting due to 1 previous error
+