Closed
Description
I tried this code:
#![feature(let_else)]
const fn foo(a: Option<i32>) -> i32 {
let Some(a) = a else {
return 42
};
a + 1
}
fn main() {
const A: i32 = foo(None);
const B: i32 = foo(Some(1));
println!("{} {}", A, B);
}
I expected to see this happen: The code should compile and print "42 2".
Instead, this happened: The evaluation of the constant B
fails with StorageLive on a local that was already live
.
This code last compiled with nightly-2022-09-15-x86_64-unknown-linux-gnu (750bd1a7f 2022-09-14)
and first failed with nightly-2022-09-16-x86_64-unknown-linux-gnu (cf9ed0dd5 2022-09-15)
.
Meta
rustc --version --verbose
:
rustc 1.65.0-nightly (95a992a68 2022-09-16)
binary: rustc
commit-hash: 95a992a68694d8bf3959bd2c0ac27ce9e9208b59
commit-date: 2022-09-16
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 15.0.0
Backtrace
error[E0080]: evaluation of constant value failed
--> main.rs:4:14
|
4 | let Some(a) = a else {
| ^
| |
| StorageLive on a local that was already live
| inside `foo` at main.rs:4:14
...
13 | const B: i32 = foo(Some(1));
| ------------ inside `B` at main.rs:13:20
error: aborting due to previous error
For more information about this error, try `rustc --explain E0080`.