# Can we deprecate 'T: Drop' trait bounds?

**URL:** <https://internals.rust-lang.org/t/can-we-deprecate-t-drop-trait-bounds/9238>\
**Category:** Uncategorized\
**Created:** [January 18, 2019, 8:29pm UTC](https://internals.rust-lang.org/t/can-we-deprecate-t-drop-trait-bounds/9238 "2019-01-18T20:29:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ExpHP](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/exphp/32/6208_2.png) [@ExpHP](https://internals.rust-lang.org/u/ExpHP)\
**Post date:** [January 18, 2019, 8:29pm UTC](https://internals.rust-lang.org/t/can-we-deprecate-t-drop-trait-bounds/9238/1 "2019-01-18T20:29:06Z")

</div>

Is there _any legitimate use_ for a `T: Drop` trait bound?

As far as I can tell:

- There are no methods you can call on a `T: Drop`.
- AFAICT the only thing that such a bound enables you do is to unsize a value to `dyn Drop`. (but what good is `dyn Drop` for?)
- Usage of `T: Drop` for specialization is **dangerous and wrong.** The type `(Vec<i32>, Vec<i32>)` does not impl `Drop`. You should specialize on `Copy` instead.

* * *

**Edit (2019/09/5):** _Wow._ There is a valid use case [in `pin-project`](https://github.com/rust-lang/rfcs/pull/2632#issuecomment-528461395).

---

<div class="post-metadata">

**Author:** ![scottmcm](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/scottmcm/32/2355_2.png) [@scottmcm](https://internals.rust-lang.org/u/scottmcm)\
**Post date:** [January 18, 2019, 8:39pm UTC](https://internals.rust-lang.org/t/can-we-deprecate-t-drop-trait-bounds/9238/2 "2019-01-18T20:39:17Z")

</div>

Sounds like a useful clippy lint, at the very least.

---

<div class="post-metadata">

**Author:** ![felix.s](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/felix.s/32/8073_2.png) [@felix.s](https://internals.rust-lang.org/u/felix.s)\
**Post date:** [January 18, 2019, 9:21pm UTC](https://internals.rust-lang.org/t/can-we-deprecate-t-drop-trait-bounds/9238/3 "2019-01-18T21:21:36Z")

</div>

Please do. In fact, I was going to propose it as a part of a [larger proposal to overhaul `Drop`](https://github.com/rust-lang/rfcs/pull/2534#discussion_r244580008).

---

<div class="post-metadata">

**Author:** ![cuviper](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/cuviper/32/1897_2.png) [@cuviper](https://internals.rust-lang.org/u/cuviper)\
**Post date:** [January 19, 2019, 12:31am UTC](https://internals.rust-lang.org/t/can-we-deprecate-t-drop-trait-bounds/9238/4 "2019-01-19T00:31:14Z")

</div>

Using `Drop::drop` in any way is [E0040](https://doc.rust-lang.org/stable/error-index.html#E0040), even just to mention it:

```rust
    let _ = <Vec<i32> as Drop>::drop;

```

I could see a lint about `Drop` bounds as an extension of this.

Have you seen `T: Drop` in practice?

---

<div class="post-metadata">

**Author:** ![sfackler](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/sfackler/32/9_2.png) [@sfackler](https://internals.rust-lang.org/u/sfackler)\
**Post date:** [January 19, 2019, 12:52am UTC](https://internals.rust-lang.org/t/can-we-deprecate-t-drop-trait-bounds/9238/5 "2019-01-19T00:52:21Z")

</div>

I’ve seen new Rust programmers try to use `Drop` bounds as “has a destructor”. I think a lint would definitely make sense!

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [April 19, 2019, 12:52am UTC](https://internals.rust-lang.org/t/can-we-deprecate-t-drop-trait-bounds/9238/6 "2019-04-19T00:52:22Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
