Add regression test for overwriting qualifs by assignment

This commit is contained in:
Oliver Scherer 2018-11-21 11:47:44 +01:00
parent e05b61ccd8
commit 22aebd57c8
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,13 @@
// compile-pass
#![feature(const_let)]
use std::cell::Cell;
const FOO: &Option<Cell<usize>> = {
let mut a = Some(Cell::new(0));
a = None; // resets `qualif(a)` to `qualif(None)`
&{a}
};
fn main() {}

View File

@ -0,0 +1,9 @@
error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
--> $DIR/qualif_overwrite.rs:8:5
|
LL | &{a} //~ ERROR cannot borrow a constant which may contain interior mutability
| ^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0492`.