Add regression test for overwriting qualifs by assignment
This commit is contained in:
parent
e05b61ccd8
commit
22aebd57c8
2 changed files with 22 additions and 0 deletions
13
src/test/ui/consts/qualif_overwrite.rs
Normal file
13
src/test/ui/consts/qualif_overwrite.rs
Normal 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() {}
|
||||
9
src/test/ui/consts/qualif_overwrite.stderr
Normal file
9
src/test/ui/consts/qualif_overwrite.stderr
Normal 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`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue