summaryrefslogtreecommitdiffstats
path: root/src/test/ui/consts/qualif-indirect-mutation-pass.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/consts/qualif-indirect-mutation-pass.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/ui/consts/qualif-indirect-mutation-pass.rs b/src/test/ui/consts/qualif-indirect-mutation-pass.rs
new file mode 100644
index 000000000..06af6a03b
--- /dev/null
+++ b/src/test/ui/consts/qualif-indirect-mutation-pass.rs
@@ -0,0 +1,24 @@
+// compile-flags: --crate-type=lib
+// check-pass
+#![feature(const_mut_refs)]
+#![feature(const_precise_live_drops)]
+
+// Mutable reference allows only mutation of !Drop place.
+pub const fn f() {
+ let mut x: (Option<String>, u32) = (None, 0);
+ let mut a = 10;
+ *(&mut a) = 11;
+ x.1 = a;
+}
+
+// Mutable reference allows only mutation of !Drop place.
+pub const fn g() {
+ let mut a: (u32, Option<String>) = (0, None);
+ let _ = &mut a.0;
+}
+
+// Shared reference does not allow for mutation.
+pub const fn h() {
+ let x: Option<String> = None;
+ let _ = &x;
+}