]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/qualif_overwrite.rs
Rollup merge of #64603 - gilescope:unused-lifetime-warning, r=matthewjasper
[rust.git] / src / test / ui / consts / qualif_overwrite.rs
1 use std::cell::Cell;
2
3 // this is overly conservative. The reset to `None` should clear `a` of all qualifications
4 // while we could fix this, it would be inconsistent with `qualif_overwrite_2.rs`.
5 // We can fix this properly in the future by allowing constants that do not depend on generics
6 // to be checked by an analysis on the final value instead of looking at the body.
7 const FOO: &Option<Cell<usize>> = {
8     let mut a = Some(Cell::new(0));
9     a = None; // sets `qualif(a)` to `qualif(a) | qualif(None)`
10     &{a} //~ ERROR cannot borrow a constant which may contain interior mutability
11 };
12
13 fn main() {}