mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
Add regression test for overwriting qualifs by assignment
This commit is contained in:
parent
e05b61ccd8
commit
22aebd57c8
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…
Reference in New Issue
Block a user