// Ensure that we point the user to the erroneous borrow but not to any subsequent borrows of that
// initial one.
-const _X: i32 = {
+const _: i32 = {
let mut a = 5;
let p = &mut a; //~ ERROR references in constants may only refer to immutable values
***ppp
};
+const _: std::cell::Cell<i32> = {
+ let mut a = std::cell::Cell::new(5);
+ let p = &a; //~ ERROR cannot borrow a constant which may contain interior mutability
+
+ let reborrow = {p};
+ let pp = &reborrow;
+ let ppp = &pp;
+ a
+};
+
fn main() {}
LL | let p = &mut a;
| ^^^^^^ constants require immutable values
-error: aborting due to previous error
+error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
+ --> $DIR/const-multi-ref.rs:16:13
+ |
+LL | let p = &a;
+ | ^^
+
+error: aborting due to 2 previous errors
-For more information about this error, try `rustc --explain E0017`.
+Some errors have detailed explanations: E0017, E0492.
+For more information about an error, try `rustc --explain E0017`.