2019-11-22 18:14:24 -06:00
|
|
|
// Ensure that we point the user to the erroneous borrow but not to any subsequent borrows of that
|
|
|
|
// initial one.
|
|
|
|
|
2019-11-26 14:10:44 -06:00
|
|
|
const _: i32 = {
|
2019-09-17 18:25:26 -05:00
|
|
|
let mut a = 5;
|
2020-06-15 12:05:24 -05:00
|
|
|
let p = &mut a; //~ ERROR mutable references are not allowed in constants
|
2019-09-17 18:25:26 -05:00
|
|
|
|
2019-11-22 18:14:24 -06:00
|
|
|
let reborrow = {p};
|
2019-09-17 18:25:26 -05:00
|
|
|
let pp = &reborrow;
|
|
|
|
let ppp = &pp;
|
|
|
|
***ppp
|
|
|
|
};
|
|
|
|
|
2019-11-26 14:10:44 -06:00
|
|
|
const _: std::cell::Cell<i32> = {
|
|
|
|
let mut a = std::cell::Cell::new(5);
|
2020-12-27 11:33:56 -06:00
|
|
|
let p = &a; //~ ERROR borrowed element may contain interior mutability
|
2019-11-26 14:10:44 -06:00
|
|
|
|
|
|
|
let reborrow = {p};
|
|
|
|
let pp = &reborrow;
|
|
|
|
let ppp = &pp;
|
|
|
|
a
|
|
|
|
};
|
|
|
|
|
2019-09-17 18:25:26 -05:00
|
|
|
fn main() {}
|