diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-11-21 11:47:44 +0100 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-11-21 11:47:44 +0100 |
| commit | 22aebd57c8ed5344260059abebbb938683ab4d91 (patch) | |
| tree | 86e3eff514483bdbd5b2be641c9d67d097914046 | |
| parent | e05b61ccd8fcb4bb4fd12085fc13522b940e7618 (diff) | |
Add regression test for overwriting qualifs by assignment
| -rw-r--r-- | src/test/ui/consts/qualif_overwrite.rs | 13 | ||||
| -rw-r--r-- | src/test/ui/consts/qualif_overwrite.stderr | 9 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/test/ui/consts/qualif_overwrite.rs b/src/test/ui/consts/qualif_overwrite.rs new file mode 100644 index 00000000000..65e182945bf --- /dev/null +++ b/src/test/ui/consts/qualif_overwrite.rs @@ -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() {} diff --git a/src/test/ui/consts/qualif_overwrite.stderr b/src/test/ui/consts/qualif_overwrite.stderr new file mode 100644 index 00000000000..b24c0fa70f0 --- /dev/null +++ b/src/test/ui/consts/qualif_overwrite.stderr @@ -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`. |
