Open
Description
Given the following code:
pub struct Wrap(String);
impl Wrap {
pub const fn into_inner(self) -> String {
self.0
}
}
The current output is:
error[E0493]: destructors cannot be evaluated at compile-time
--> src/lib.rs:4:29
|
4 | pub const fn into_inner(self) -> String {
| ^^^^ constant functions cannot evaluate destructors
5 | self.0
6 | }
| - value is dropped here
This error is clearly wrong: self
is not dropped, as it's been moved out of. In fact, no destructors are run, so this should be able to compile. If it shouldn't compile, the error should be changed to not be incorrect.
This seems to be an issue in the drop suppression when moving out field-wise; using e.g. mem::forget
works to suppress the destructor and allow the function to compile. I was unable to trick the compiler to accept the function with ManuallyDrop
, as extracting the wrapped value requires manifesting a wrapper again, which triggers E0493 "destructors cannot be evaluated at compile-time".
@rustbot label: +A-const-fn +A-destructors