blob: b38f7900e8e5e89c7959ea6f85caedf40c77b9de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
// check that existing borrows due to a closure capture give a special note
fn move_while_borrowed(x: String) {
let f = || x.len();
let y = x; //~ ERROR
f.use_ref();
}
fn borrow_mut_while_borrowed(mut x: i32) {
let f = || x;
let y = &mut x; //~ ERROR
f.use_ref();
}
fn drop_while_borrowed() {
let f;
{
let x = 1;
f = || x; //~ ERROR
}
f.use_ref();
}
fn assign_while_borrowed(mut x: i32) {
let f = || x;
x = 1; //~ ERROR
f.use_ref();
}
fn copy_while_borrowed_mut(mut x: i32) {
let f = || x = 0;
let y = x; //~ ERROR
f.use_ref();
}
fn borrow_while_borrowed_mut(mut x: i32) {
let f = || x = 0;
let y = &x; //~ ERROR
f.use_ref();
}
fn borrow_mut_while_borrowed_mut(mut x: i32) {
let f = || x = 0;
let y = &mut x; //~ ERROR
f.use_ref();
}
fn drop_while_borrowed_mut() {
let f;
{
let mut x = 1;
f = || x = 0; //~ ERROR
}
f.use_ref();
}
fn assign_while_borrowed_mut(mut x: i32) {
let f = || x = 0;
x = 1; //~ ERROR
f.use_ref();
}
fn copy_while_borrowed_unique(x: &mut i32) {
let f = || *x = 0;
let y = x; //~ ERROR
f.use_ref();
}
fn borrow_while_borrowed_unique(x: &mut i32) {
let f = || *x = 0;
let y = &x; //~ ERROR
f.use_ref();
}
fn borrow_mut_while_borrowed_unique(mut x: &mut i32) {
let f = || *x = 0;
let y = &mut x; //~ ERROR
f.use_ref();
}
fn drop_while_borrowed_unique() {
let mut z = 1;
let f;
{
let x = &mut z;
f = || *x = 0; //~ ERROR
}
f.use_ref();
}
fn assign_while_borrowed_unique(x: &mut i32) {
let f = || *x = 0;
*x = 1; //~ ERROR
f.use_ref();
}
fn main() {}
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
impl<T> Fake for T { }
|