Skip to content

Commit 237cdad

Browse files
committed
Elaborate on const Drop fields
1 parent 4dea80c commit 237cdad

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

const-generic-const-fn-bounds.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ Then you are allowed to actually let a value of `SomeDropType` get dropped withi
8383
evaluation. This means `(SomeDropType(&Cell::new(42)), 42).1` is now allowed, because we can prove
8484
that everything from the creation of the value to the destruction is const evaluable.
8585

86+
Note that all fields of types with a `const Drop` impl must have `const Drop` impls, too, as the
87+
compiler will automatically generate `Drop::drop` calls to the fields:
88+
89+
```rust
90+
struct Foo;
91+
impl Drop for Foo { fn drop(&mut self) {} }
92+
struct Bar(Foo);
93+
impl const Drop for Foo { fn drop(&mut self) {} } // not allowed
94+
```
95+
8696
## Runtime uses don't have `const` restrictions?
8797

8898
`impl const` blocks additionally generate impls that are not const if any generic

0 commit comments

Comments
 (0)