]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/issue-63952.rs
Rollup merge of #81697 - xfix:every-doc-alias, r=Mark-Simulacrum
[rust.git] / src / test / ui / consts / issue-63952.rs
1 // Regression test for #63952, shouldn't hang.
2
3 #[repr(C)]
4 #[derive(Copy, Clone)]
5 struct SliceRepr {
6     ptr: *const u8,
7     len: usize,
8 }
9
10 union SliceTransmute {
11     repr: SliceRepr,
12     slice: &'static [u8],
13 }
14
15 // bad slice: length too big to even exist anywhere
16 const SLICE_WAY_TOO_LONG: &[u8] = unsafe { //~ ERROR: it is undefined behavior to use this value
17     SliceTransmute {
18         repr: SliceRepr {
19             ptr: &42,
20             len: usize::MAX,
21         },
22     }
23     .slice
24 };
25
26 fn main() {}