]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/qualif-indirect-mutation-pass.rs
Rollup merge of #107058 - clubby789:eqeq-homoglyph, r=wesleywiser
[rust.git] / tests / ui / consts / qualif-indirect-mutation-pass.rs
1 // compile-flags: --crate-type=lib
2 // check-pass
3 #![feature(const_mut_refs)]
4 #![feature(const_precise_live_drops)]
5
6 // Mutable reference allows only mutation of !Drop place.
7 pub const fn f() {
8     let mut x: (Option<String>, u32) = (None, 0);
9     let mut a = 10;
10     *(&mut a) = 11;
11     x.1 = a;
12 }
13
14 // Mutable reference allows only mutation of !Drop place.
15 pub const fn g() {
16     let mut a: (u32, Option<String>) = (0, None);
17     let _ = &mut a.0;
18 }
19
20 // Shared reference does not allow for mutation.
21 pub const fn h() {
22     let x: Option<String> = None;
23     let _ = &x;
24 }