about summary refs log tree commit diff
path: root/tests/ui/codegen
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2025-08-26 11:13:03 +0200
committerNikita Popov <npopov@redhat.com>2025-08-26 16:16:23 +0200
commitc3ab409b4fa3b1fb18f34877d9811bb502ed507f (patch)
tree05ab8323d24155dd4d9459c873ce3f2358141503 /tests/ui/codegen
parentace9a74442aec13c75532d34e15d97428056866d (diff)
downloadrust-c3ab409b4fa3b1fb18f34877d9811bb502ed507f.tar.gz
rust-c3ab409b4fa3b1fb18f34877d9811bb502ed507f.zip
Use captures(address) instead of captures(none) for indirect args
While provenance cannot be captured through these arguments, the
address / object identity can.
Diffstat (limited to 'tests/ui/codegen')
-rw-r--r--tests/ui/codegen/indirect-nocapture.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/ui/codegen/indirect-nocapture.rs b/tests/ui/codegen/indirect-nocapture.rs
new file mode 100644
index 00000000000..78024a94c0d
--- /dev/null
+++ b/tests/ui/codegen/indirect-nocapture.rs
@@ -0,0 +1,15 @@
+// Regression test for issue #137668 where an indirect argument have been marked as nocapture
+// despite the fact that callee did in fact capture the address.
+//
+//@ run-pass
+//@ compile-flags: -Copt-level=2
+
+#[inline(never)]
+pub fn f(a: [u32; 64], b: [u32; 64]) -> bool {
+    &a as *const _ as usize != &b as *const _ as usize
+}
+
+fn main() {
+    static S: [u32; 64] = [0; 64];
+    assert!(f(S, S));
+}