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