]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrow-raw-address-of-mutability.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / borrow-raw-address-of-mutability.rs
1 #![feature(raw_ref_op)]
2
3 fn mutable_address_of() {
4     let x = 0;
5     let y = &raw mut x;                 //~ ERROR cannot borrow
6 }
7
8 fn mutable_address_of_closure() {
9     let x = 0;
10     let mut f = || {
11         let y = &raw mut x;             //~ ERROR cannot borrow
12     };
13     f();
14 }
15
16 fn mutable_address_of_imm_closure() {
17     let mut x = 0;
18     let f = || {
19         let y = &raw mut x;
20     };
21     f();                                //~ ERROR cannot borrow
22 }
23
24 fn make_fn<F: Fn()>(f: F) -> F { f }
25
26 fn mutable_address_of_fn_closure() {
27     let mut x = 0;
28     let f = make_fn(|| {
29         let y = &raw mut x;             //~ ERROR cannot borrow
30     });
31     f();
32 }
33
34 fn mutable_address_of_fn_closure_move() {
35     let mut x = 0;
36     let f = make_fn(move || {
37         let y = &raw mut x;             //~ ERROR cannot borrow
38     });
39     f();
40 }
41
42 fn main() {}