Unfamiliar trait bound syntax

While looking at the source code for Option::ok_or() I saw a trait bound that looks like E: ~const Drop.

My question is, what does the ~const part mean? I'm assuming it's nightly-only since the rustc_const_unstable attribute on top of the method says as much.

1 Like

https://github.com/rust-lang/rust/issues/67792

4 Likes

Wow, that’s a weird syntax, I didn’t even know that exists. (I did know of ~const Trait, but not of this weird abuse of “~const Drop” notation). The compiler apparently isn’t fully aware of the abuse of notation here either; it actually thinks that T: ~const Drop implies T: Drop, and unsoundness entails

9 Likes

And here’s a second issue I found looking into const Drop right now

3 Likes

Oh, that truly looks awful.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.