]> git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/issue-102117.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / 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 //~^ ERROR the parameter type `T` may not live long enough
18 //~| ERROR the parameter type `T` may not live long enough
19 &VTable {
20 layout: Layout::new::<T>(),
21 type_id: TypeId::of::<T>(),
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() {}