about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2023-03-19 10:04:44 +0000
committerCamille GILLOT <gillot.camille@gmail.com>2023-03-28 18:05:12 +0000
commit3102722ef4aa61b02f78f98403ceef588ed791ca (patch)
tree25e0eb25e716a0fa953b3c16cec9d7685b85c9de /tests
parent84487b212daa3916b52ab1469afba161760e3081 (diff)
downloadrust-3102722ef4aa61b02f78f98403ceef588ed791ca.tar.gz
rust-3102722ef4aa61b02f78f98403ceef588ed791ca.zip
Skip no_mangle if the item has no name.
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/attributes/no-mangle-closure.rs11
-rw-r--r--tests/ui/attributes/no-mangle-closure.stderr8
2 files changed, 19 insertions, 0 deletions
diff --git a/tests/ui/attributes/no-mangle-closure.rs b/tests/ui/attributes/no-mangle-closure.rs
new file mode 100644
index 00000000000..c76baa27f38
--- /dev/null
+++ b/tests/ui/attributes/no-mangle-closure.rs
@@ -0,0 +1,11 @@
+// Check that we do not ICE when `no_mangle` is applied to something that has no name.
+
+#![crate_type = "lib"]
+#![feature(stmt_expr_attributes)]
+
+pub struct S([usize; 8]);
+
+pub fn outer_function(x: S, y: S) -> usize {
+    (#[no_mangle] || y.0[0])()
+    //~^ ERROR `#[no_mangle]` cannot be used on a closure as it has no name
+}
diff --git a/tests/ui/attributes/no-mangle-closure.stderr b/tests/ui/attributes/no-mangle-closure.stderr
new file mode 100644
index 00000000000..949eb70510e
--- /dev/null
+++ b/tests/ui/attributes/no-mangle-closure.stderr
@@ -0,0 +1,8 @@
+error: `#[no_mangle]` cannot be used on a closure as it has no name
+  --> $DIR/no-mangle-closure.rs:9:6
+   |
+LL |     (#[no_mangle] || y.0[0])()
+   |      ^^^^^^^^^^^^
+
+error: aborting due to previous error
+