]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/issue-102117.rs
Auto merge of #106090 - WaffleLapkin:dereffffffffff, r=Nilstrieb
[rust.git] / tests / ui / consts / issue-102117.rs
1 #![feature(inline_const, const_type_id)]
2
3 use std::alloc::Layout;
4 use std::any::TypeId;
5 use std::mem::transmute;
6 use std::ptr::drop_in_place;
7
8 pub struct VTable {
9     layout: Layout,
10     type_id: TypeId,
11     drop_in_place: unsafe fn(*mut ()),
12 }
13
14 impl VTable {
15     pub fn new<T>() -> &'static Self {
16         const {
17             &VTable {
18                 layout: Layout::new::<T>(),
19                 type_id: TypeId::of::<T>(),
20                 //~^ ERROR the parameter type `T` may not live long enough
21                 //~| ERROR the parameter type `T` may not live long enough
22                 drop_in_place: unsafe {
23                     transmute::<unsafe fn(*mut T), unsafe fn(*mut ())>(drop_in_place::<T>)
24                 },
25             }
26         }
27     }
28 }
29
30 fn main() {}