]> git.lizzy.rs Git - rust.git/blob - src/test/ui/E0501.rs
Rollup merge of #57132 - daxpedda:master, r=steveklabnik
[rust.git] / src / test / ui / E0501.rs
1 // ignore-tidy-linelength
2 // revisions: ast mir
3 //[mir]compile-flags: -Z borrowck=mir
4
5 fn inside_closure(x: &mut i32) {
6 }
7
8 fn outside_closure_1(x: &mut i32) {
9 }
10
11 fn outside_closure_2(x: &i32) {
12 }
13
14 fn foo(a: &mut i32) {
15     let bar = || {
16         inside_closure(a)
17     };
18     outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access
19     //[mir]~^ ERROR cannot borrow `*a` as mutable because previous closure requires unique access
20
21     outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access
22     //[mir]~^ ERROR cannot borrow `*a` as immutable because previous closure requires unique access
23
24     drop(bar);
25 }
26
27 fn main() {
28 }