Skip to content

Commit 22aebd5

Browse files
committed
Add regression test for overwriting qualifs by assignment
1 parent e05b61c commit 22aebd5

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// compile-pass
2+
3+
#![feature(const_let)]
4+
5+
use std::cell::Cell;
6+
7+
const FOO: &Option<Cell<usize>> = {
8+
let mut a = Some(Cell::new(0));
9+
a = None; // resets `qualif(a)` to `qualif(None)`
10+
&{a}
11+
};
12+
13+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
2+
--> $DIR/qualif_overwrite.rs:8:5
3+
|
4+
LL | &{a} //~ ERROR cannot borrow a constant which may contain interior mutability
5+
| ^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0492`.

0 commit comments

Comments
 (0)