Skip to content

Commit 355dc5c

Browse files
Regression test for issue 85435.
Apply suggestions from code review: 1. (removing confusing comment from my test, since the comment reflects the bad undesirable behavior that is being fixed here.) 2. test THIR unsafeck too. Co-authored-by: Léo Lanteri Thauvin <[email protected]>
1 parent 75dc963 commit 355dc5c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// check-pass
2+
// revisions: mir thir
3+
// [thir]compile-flags: -Z thir-unsafeck
4+
5+
// This is issue #85435. But the real story is reflected in issue #85561, where
6+
// a bug in the implementation of feature(capture_disjoint_fields) () was
7+
// exposed to non-feature-gated code by a diagnostic changing PR that removed
8+
// the gating in one case.
9+
10+
// This test is double-checking that the case of interest continues to work as
11+
// expected in the *absence* of that feature gate. At the time of this writing,
12+
// enabling the feature gate will cause this test to fail. We obviously cannot
13+
// stabilize that feature until it can correctly handle this test.
14+
15+
fn main() {
16+
let val: u8 = 5;
17+
let u8_ptr: *const u8 = &val;
18+
let _closure = || {
19+
unsafe {
20+
let tmp = *u8_ptr;
21+
tmp
22+
23+
// Just dereferencing and returning directly compiles fine:
24+
// *u8_ptr
25+
}
26+
};
27+
}

0 commit comments

Comments
 (0)