]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/const_forget.rs
Rollup merge of #106951 - tmiasko:rm-simplify-initial, r=oli-obk
[rust.git] / tests / ui / consts / const_forget.rs
1 // check-pass
2
3 use std::mem::forget;
4
5 const _: () = forget(0i32);
6 const _: () = forget(Vec::<Vec<Box<i32>>>::new());
7
8 // Writing this function signature without const-forget
9 // triggers compiler errors:
10 // 1) That we use a non-const fn inside a const fn
11 // 2) without the forget, it complains about the destructor of Box
12 //
13 // FIXME: this method cannot be called in const-eval yet, as Box isn't
14 // const constructable
15 #[allow(unused)]
16 const fn const_forget_box<T: ?Sized>(b: Box<T>) {
17     forget(b);
18 }
19
20 fn main() {}