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