]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-multi-ref.rs
Rollup merge of #98609 - TaKO8Ki:fix-ice-for-associated-constant-generics, r=lcnr
[rust.git] / src / test / ui / consts / const-multi-ref.rs
1 // Ensure that we point the user to the erroneous borrow but not to any subsequent borrows of that
2 // initial one.
3
4 const _: i32 = {
5     let mut a = 5;
6     let p = &mut a; //~ ERROR mutable references are not allowed in constants
7
8     let reborrow = {p};
9     let pp = &reborrow;
10     let ppp = &pp;
11     ***ppp
12 };
13
14 const _: std::cell::Cell<i32> = {
15     let mut a = std::cell::Cell::new(5);
16     let p = &a; //~ ERROR borrowed element may contain interior mutability
17
18     let reborrow = {p};
19     let pp = &reborrow;
20     let ppp = &pp;
21     a
22 };
23
24 fn main() {}