Skip to content

ICE when using unsafe blocks + UnsafeCell + a move #21945

Closed
@jroesch

Description

@jroesch

This is just some experimentation on my part that triggered an ICE. I may have time to investigate later but for now here is the smallest chunk of code I have and a playground session.

use std::thunk::Thunk;
use std::cell::UnsafeCell;
use std::mem::transmute;

struct Lazy<T> {
    value: UnsafeCell<Option<T>>,
    thunk: UnsafeCell<Option<Thunk<(), T>>>,
}

impl<T> Lazy<T> {
    fn value(&self) -> &T {
        unsafe { 
            let value = self.value.get();
            // deleted some code here
            let raw_value = &(*value).unwrap();
            transmute(raw_value)
        }
    }
}

fn main() {
}

http://is.gd/L2RIMD

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions