about summary refs log tree commit diff
path: root/tests/ui/unsafe-binders
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-05-23 10:18:05 +0000
committerMichael Goulet <michael@errs.io>2025-05-23 10:43:13 +0000
commit04ddafc53ce0e045bae86ad0b20f5be540ca0e84 (patch)
treec66db0a0b53249d0fca3700939a69a5cc3a93cac /tests/ui/unsafe-binders
parent52bf0cf795dfecc8b929ebb1c1e2545c3f41d4c9 (diff)
downloadrust-04ddafc53ce0e045bae86ad0b20f5be540ca0e84.tar.gz
rust-04ddafc53ce0e045bae86ad0b20f5be540ca0e84.zip
Properly analyze captures from unsafe binders
Diffstat (limited to 'tests/ui/unsafe-binders')
-rw-r--r--tests/ui/unsafe-binders/cat-projection.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/unsafe-binders/cat-projection.rs b/tests/ui/unsafe-binders/cat-projection.rs
new file mode 100644
index 00000000000..dd7a78d59b3
--- /dev/null
+++ b/tests/ui/unsafe-binders/cat-projection.rs
@@ -0,0 +1,21 @@
+//@ check-pass
+
+#![feature(unsafe_binders)]
+#![allow(incomplete_features)]
+
+use std::unsafe_binder::unwrap_binder;
+
+#[derive(Copy, Clone)]
+pub struct S([usize; 8]);
+
+// Regression test for <https://github.com/rust-lang/rust/issues/141418>.
+pub fn by_value(x: unsafe<'a> S) -> usize {
+    unsafe { (|| unwrap_binder!(x).0[0])() }
+}
+
+// Regression test for <https://github.com/rust-lang/rust/issues/141417>.
+pub fn by_ref(x: unsafe<'a> &'a S) -> usize {
+    unsafe { (|| unwrap_binder!(x).0[0])() }
+}
+
+fn main() {}