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