Skip to content

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

@reem

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions