2df14c3701
**What it does:** Checks for generics with `std::ops::Drop` as bounds. **Why is this bad?** `Drop` bounds do not really accomplish anything. A type may have compiler-generated drop glue without implementing the `Drop` trait itself. The `Drop` trait also only has one method, `Drop::drop`, and that function is by fiat not callable in user code. So there is really no use case for using `Drop` in trait bounds. **Known problems:** None. **Example:** ```rust fn foo<T: Drop>() {} ```
17 lines
508 B
Plaintext
17 lines
508 B
Plaintext
error: Bounds of the form `T: Drop` are useless. Use `std::mem::needs_drop` to detect if a type has drop glue.
|
|
--> $DIR/drop_bounds.rs:2:11
|
|
|
|
|
LL | fn foo<T: Drop>() {}
|
|
| ^^^^
|
|
|
|
|
= note: #[deny(clippy::drop_bounds)] on by default
|
|
|
|
error: Bounds of the form `T: Drop` are useless. Use `std::mem::needs_drop` to detect if a type has drop glue.
|
|
--> $DIR/drop_bounds.rs:3:22
|
|
|
|
|
LL | fn bar<T>() where T: Drop {}
|
|
| ^^^^
|
|
|
|
error: aborting due to 2 previous errors
|
|
|