Skip to content

Box implementation for Drop does no customization. Seems the compiler is responsible for that #2260

@dadepo

Description

@dadepo

In Chapter 15, section 3 you have

For example, Box customizes Drop to deallocate the space on the heap that the box points to

source: https://doc.rust-lang.org/book/ch15-03-drop.html

I looked into the implementation of Drop for Box with the intention of seeing how such an implementation would look like and this is what I found:

#[stable(feature = "rust1", since = "1.0.0")]
unsafe impl<#[may_dangle] T: ?Sized> Drop for Box<T> {
    fn drop(&mut self) {
        // FIXME: Do nothing, drop is currently performed by compiler.
    }
}

So I do not think the quoted snippet from the book is technically correct.

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