Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

ices/102117.rs: fixed with errors #1444

Merged
merged 1 commit into from
Oct 13, 2022
Merged

ices/102117.rs: fixed with errors #1444

merged 1 commit into from
Oct 13, 2022

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#102117

#![crate_type = "lib"]
#![feature(inline_const, const_type_id)]

use std::alloc::Layout;
use std::any::TypeId;
use std::mem::transmute;
use std::ptr::drop_in_place;

pub struct VTable {
    layout: Layout,
    type_id: TypeId,
    drop_in_place: unsafe fn(*mut ()),
}

impl VTable {
    pub fn new<T>() -> &'static Self {
        const {
            &VTable {
                layout: Layout::new::<T>(),
                type_id: TypeId::of::<T>(),
                drop_in_place: unsafe {
                    transmute::<unsafe fn(*mut T), unsafe fn(*mut ())>(drop_in_place::<T>)
                },
            }
        }
    }
}
=== stdout ===
=== stderr ===
error[E0310]: the parameter type `T` may not live long enough
  --> /home/runner/work/glacier/glacier/ices/102117.rs:17:9
   |
17 | /         const {
18 | |             &VTable {
19 | |                 layout: Layout::new::<T>(),
20 | |                 type_id: TypeId::of::<T>(),
...  |
24 | |             }
25 | |         }
   | |_________^ ...so that the type `T` will meet its required lifetime bounds
   |
help: consider adding an explicit lifetime bound...
   |
16 |     pub fn new<T: 'static>() -> &'static Self {
   |                 +++++++++

error: aborting due to previous error

For more information about this error, try `rustc --explain E0310`.
==============

=== stdout ===
=== stderr ===
error[E0310]: the parameter type `T` may not live long enough
  --> /home/runner/work/glacier/glacier/ices/102117.rs:17:9
   |
17 | /         const {
18 | |             &VTable {
19 | |                 layout: Layout::new::<T>(),
20 | |                 type_id: TypeId::of::<T>(),
...  |
24 | |             }
25 | |         }
   | |_________^ ...so that the type `T` will meet its required lifetime bounds
   |
help: consider adding an explicit lifetime bound...
   |
16 |     pub fn new<T: 'static>() -> &'static Self {
   |                 +++++++++

error: aborting due to previous error

For more information about this error, try `rustc --explain E0310`.
==============
@JohnTitor JohnTitor merged commit 267777c into master Oct 13, 2022
@JohnTitor JohnTitor deleted the autofix/ices/102117.rs branch October 13, 2022 12:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants