Skip to content

Commit 4742bbb

Browse files
committed
Regression test for issue 85435.
1 parent 1f130fb commit 4742bbb

File tree

1 file changed

+28
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)