Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dadepo opened this issue Feb 15, 2020 · 0 comments · Fixed by #2350
Closed

Comments

@dadepo
Copy link

dadepo commented Feb 15, 2020

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.

@dadepo dadepo changed the title Box implementation for Drop does no customisation. The compiler is responsible for that! Box implementation for Drop does no customization. Seems the compiler is responsible for that Feb 15, 2020
steveklabnik added a commit that referenced this issue Jun 1, 2020
Technically box is still special so this is in the compiler, not in a Drop impl.

Fixes #2260
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant