2021-10-22 19:00:00 -05:00
|
|
|
// compile-flags: --crate-type=lib
|
|
|
|
// check-pass
|
|
|
|
#![feature(const_mut_refs)]
|
|
|
|
#![feature(const_precise_live_drops)]
|
|
|
|
|
2021-10-29 19:00:00 -05:00
|
|
|
// Mutable reference allows only mutation of !Drop place.
|
2021-10-22 19:00:00 -05:00
|
|
|
pub const fn f() {
|
|
|
|
let mut x: (Option<String>, u32) = (None, 0);
|
|
|
|
let mut a = 10;
|
|
|
|
*(&mut a) = 11;
|
|
|
|
x.1 = a;
|
|
|
|
}
|
|
|
|
|
2021-10-29 19:00:00 -05:00
|
|
|
// Mutable reference allows only mutation of !Drop place.
|
2021-10-22 19:00:00 -05:00
|
|
|
pub const fn g() {
|
|
|
|
let mut a: (u32, Option<String>) = (0, None);
|
|
|
|
let _ = &mut a.0;
|
|
|
|
}
|
2021-10-29 19:00:00 -05:00
|
|
|
|
|
|
|
// Shared reference does not allow for mutation.
|
|
|
|
pub const fn h() {
|
|
|
|
let x: Option<String> = None;
|
|
|
|
let _ = &x;
|
|
|
|
}
|