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