Add test for promotability in let

The old const-checker conservatively reset qualifs when
`IsNotPromotable` was in the return place. Unfortunately, named
variables have `IsNotPromotable`, so this could cause promotion to fail.
This should work now.
This commit is contained in:
Dylan MacKenzie 2019-11-06 07:09:16 -08:00
parent a9b1abe6ea
commit ec5ba54ed2

View file

@ -0,0 +1,17 @@
// run-pass
use std::cell::Cell;
const X: Option<Cell<i32>> = None;
const Y: Option<Cell<i32>> = {
let x = None;
x
};
// Ensure that binding the final value of a `const` to a variable does not affect promotion.
#[allow(unused)]
fn main() {
let x: &'static _ = &X;
let y: &'static _ = &Y;
}