Skip to content

The lint docs misrepresent trait Drop #9227

Open
@kadiwa4

Description

@kadiwa4

The reason why Drop is a trait is because adding a drop method to a type is similar to implementing a trait on it.
Other than that, Drop does not really behave like a trait. If a type doesn’t implement Drop, then that doesn’t mean it lacks destructor code. For instance, String and HashMap currently don’t implement it.

Instead, core::mem::needs_drop::<T>() is used to check if dropping a T invokes a destructor.

drop_non_drop and forget_non_drop should ideally not mention the trait Drop in their name or documentation, it is misleading.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-documentationArea: Adding or improving documentationC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions