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

The lint docs misrepresent trait Drop #9227

Open
kadiwa4 opened this issue Jul 22, 2022 · 0 comments
Open

The lint docs misrepresent trait Drop #9227

kadiwa4 opened this issue Jul 22, 2022 · 0 comments
Labels
A-documentation Area: Adding or improving documentation C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages

Comments

@kadiwa4
Copy link
Contributor

kadiwa4 commented Jul 22, 2022

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.

@Alexendoo Alexendoo added C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages A-documentation Area: Adding or improving documentation labels Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documentation Area: Adding or improving documentation C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages
Projects
None yet
Development

No branches or pull requests

2 participants