Skip to content

mem::forget is unsafe, but can be written in entirely safe code #24456

Description

@reem

For instance:

fn forget<T>(val: T) { 
    let x = Rc::new((val, RefCell::new(None))); 
    *x.1.borrow_mut() = x.clone();
}

This is problematic, and an indicator that something is amiss in our rules.

cc @aturon @nikomatsakis @bstrie from IRC

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions