You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A work-around is to move the trait bounds to the `const fn`s inside.
215
213
216
214
```rust
217
-
#![feature(const_fn_trait_bound)]
218
215
#![feature(const_trait_impl)]
219
216
structCfg<C>(C);
220
217
traitCfgBase {}
@@ -232,7 +229,6 @@ impl<C> Cfg<C> {
232
229
The following code doesn't compile (which is okay) because `T` might not be `T: const Drop`.
233
230
234
231
```rust,compile_fail,E0493
235
-
#![feature(const_fn_trait_bound)]
236
232
#![feature(const_trait_impl)]
237
233
#![feature(const_mut_refs)]
238
234
#![feature(const_option)]
@@ -248,7 +244,6 @@ impl<T> const Drop for Type<T> {
248
244
The obvious solution is to add `T: ~const Drop` to the `Drop` implementation as well as to the type definition. However, this doesn't work because `~const` is not allowed to appear in the type definition.
249
245
250
246
```rust,compile_fail,E0367
251
-
#![feature(const_fn_trait_bound)]
252
247
#![feature(const_trait_impl)]
253
248
#![feature(const_mut_refs)]
254
249
#![feature(const_option)]
@@ -266,7 +261,6 @@ impl<T: ~const Drop> const Drop for Type<T> {
266
261
According to [rust-lang/rust#93028](https://github.com/rust-lang/rust/pull/93028), we can actually remove `~const` from this type definition, and the compiler permits the `Drop` implementation to have an extra `~const`. Unfortunately, this leaves a `Drop` trait bound on the type, which actually cover different types than `~const Drop` does. That's because `T: ~const Drop` means that `T` can be dropped in a constant context (n.b. this is [a special case for `Drop`](https://internals.rust-lang.org/t/pre-rfc-revamped-const-trait-impl-aka-rfc-2632/15192#const-drop-in-generic-code-6) and doesn't apply to other traits), while `T: Drop` means that `T` has a user-defined `Drop` implementation.
267
262
268
263
```rust,compile_fail,E0277
269
-
#![feature(const_fn_trait_bound)]
270
264
#![feature(const_trait_impl)]
271
265
#![feature(const_mut_refs)]
272
266
#![feature(const_option)]
@@ -283,7 +277,6 @@ let _ = Type(Some(()));
283
277
A work-around is to enclose `T` in a container that unconditionally implements `const Drop`.
0 commit comments