about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2021-05-27 03:02:08 +0200
committerGitHub <noreply@github.com>2021-05-27 03:02:08 +0200
commit9d4a6449db6624e18373cea10f1def6cb670f063 (patch)
treedda3cadd5f8914b9e6d65c2ae04abba8c63a18e0 /src/test
parent3530a7895acd495983a9cd6d7c5b2a9773337366 (diff)
parent1c1d4f907d1aa903a5fecae3fa75298042f5d8d9 (diff)
downloadrust-9d4a6449db6624e18373cea10f1def6cb670f063.tar.gz
rust-9d4a6449db6624e18373cea10f1def6cb670f063.zip
Rollup merge of #85564 - pnkfelix:issue-85435-readd-capture-disjoint-fields-gate, r=nikomatsakis
 readd capture disjoint fields gate

This readds a feature gate guard that was added in PR #83521. (Basically, there were unintended consequences to the code exposed by removing the feature gate guard.)

The root bug still remains to be resolved, as discussed in issue #85561. This is just a band-aid suitable for a beta backport.

Cc issue #85435

Note that the latter issue is unfixed until we backport this (or another fix) to 1.53 beta
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/unsafe/issue-85435-unsafe-op-in-let-under-unsafe-under-closure.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/ui/unsafe/issue-85435-unsafe-op-in-let-under-unsafe-under-closure.rs b/src/test/ui/unsafe/issue-85435-unsafe-op-in-let-under-unsafe-under-closure.rs
new file mode 100644
index 00000000000..72f7b674777
--- /dev/null
+++ b/src/test/ui/unsafe/issue-85435-unsafe-op-in-let-under-unsafe-under-closure.rs
@@ -0,0 +1,27 @@
+// check-pass
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
+// This is issue #85435. But the real story is reflected in issue #85561, where
+// a bug in the implementation of feature(capture_disjoint_fields) () was
+// exposed to non-feature-gated code by a diagnostic changing PR that removed
+// the gating in one case.
+
+// This test is double-checking that the case of interest continues to work as
+// expected in the *absence* of that feature gate. At the time of this writing,
+// enabling the feature gate will cause this test to fail. We obviously cannot
+// stabilize that feature until it can correctly handle this test.
+
+fn main() {
+    let val: u8 = 5;
+    let u8_ptr: *const u8 = &val;
+    let _closure = || {
+        unsafe {
+            let tmp = *u8_ptr;
+            tmp
+
+            // Just dereferencing and returning directly compiles fine:
+            // *u8_ptr
+        }
+    };
+}