Closed
Description
This code:
#![feature(const_if_match)]
#![feature(const_loop)]
const _: Option<Vec<i32>> = {
let mut never_returned = Some(Vec::new());
let mut always_returned = None;
let mut i = 0;
loop {
always_returned = never_returned;
never_returned = None;
i += 1;
if i == 10 {
break always_returned;
}
}
};
yields the following error:
error[E0493]: destructors cannot be evaluated at compile-time
--> src/lib.rs:7:9
|
7 | let mut always_returned = None;
| ^^^^^^^^^^^^^^^^^^^ constants cannot evaluate destructors
error: aborting due to previous error
That is not very helpful as there is nothing with a destructor on that line. The actual line where something could get dropped is line 11, and that is also the line where the drop-requiring thing is assigned into always_returned
.
Cc @rust-lang/wg-const-eval