Skip to content

Commit

Permalink
Add regression test for overwriting qualifs by assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Nov 21, 2018
1 parent e05b61c commit 22aebd5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/test/ui/consts/qualif_overwrite.rs
Original file line number Diff line number Diff line change
@@ -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() {}
9 changes: 9 additions & 0 deletions src/test/ui/consts/qualif_overwrite.stderr
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit 22aebd5

Please sign in to comment.