16
16
17
17
fn escaping_borrow_of_closure_params_1 ( ) {
18
18
let g = |x : usize , y : usize | {
19
+ //~^ NOTE reference must be valid for the scope of call-site for function
20
+ //~| NOTE ...but borrowed value is only valid for the scope of function body
21
+ //~| NOTE reference must be valid for the scope of call-site for function
22
+ //~| NOTE ...but borrowed value is only valid for the scope of function body
19
23
let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
20
24
//~^ ERROR `x` does not live long enough
21
25
//~| ERROR `y` does not live long enough
@@ -31,6 +35,10 @@ fn escaping_borrow_of_closure_params_1() {
31
35
32
36
fn escaping_borrow_of_closure_params_2 ( ) {
33
37
let g = |x : usize , y : usize | {
38
+ //~^ NOTE reference must be valid for the scope of call-site for function
39
+ //~| NOTE ...but borrowed value is only valid for the scope of function body
40
+ //~| NOTE reference must be valid for the scope of call-site for function
41
+ //~| NOTE ...but borrowed value is only valid for the scope of function body
34
42
let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
35
43
//~^ ERROR `x` does not live long enough
36
44
//~| ERROR `y` does not live long enough
@@ -64,7 +72,11 @@ fn escaping_borrow_of_fn_params_1() {
64
72
fn g < ' a > ( x : usize , y : usize ) -> Box < Fn ( bool ) -> usize + ' a > {
65
73
let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
66
74
//~^ ERROR E0373
75
+ //~| NOTE `x` is borrowed here
76
+ //~| NOTE may outlive borrowed value `x`
67
77
//~| ERROR E0373
78
+ //~| NOTE `y` is borrowed here
79
+ //~| NOTE may outlive borrowed value `y`
68
80
return Box :: new ( f) ;
69
81
} ;
70
82
@@ -75,7 +87,11 @@ fn escaping_borrow_of_fn_params_2() {
75
87
fn g < ' a > ( x : usize , y : usize ) -> Box < Fn ( bool ) -> usize + ' a > {
76
88
let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
77
89
//~^ ERROR E0373
90
+ //~| NOTE `x` is borrowed here
91
+ //~| NOTE may outlive borrowed value `x`
78
92
//~| ERROR E0373
93
+ //~| NOTE `y` is borrowed here
94
+ //~| NOTE may outlive borrowed value `y`
79
95
Box :: new ( f)
80
96
} ;
81
97
@@ -99,7 +115,11 @@ fn escaping_borrow_of_method_params_1() {
99
115
fn g < ' a > ( & self , x : usize , y : usize ) -> Box < Fn ( bool ) -> usize + ' a > {
100
116
let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
101
117
//~^ ERROR E0373
118
+ //~| NOTE `x` is borrowed here
119
+ //~| NOTE may outlive borrowed value `x`
102
120
//~| ERROR E0373
121
+ //~| NOTE `y` is borrowed here
122
+ //~| NOTE may outlive borrowed value `y`
103
123
return Box :: new ( f) ;
104
124
}
105
125
}
@@ -113,7 +133,11 @@ fn escaping_borrow_of_method_params_2() {
113
133
fn g < ' a > ( & self , x : usize , y : usize ) -> Box < Fn ( bool ) -> usize + ' a > {
114
134
let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
115
135
//~^ ERROR E0373
136
+ //~| NOTE `x` is borrowed here
137
+ //~| NOTE may outlive borrowed value `x`
116
138
//~| ERROR E0373
139
+ //~| NOTE `y` is borrowed here
140
+ //~| NOTE may outlive borrowed value `y`
117
141
Box :: new ( f)
118
142
}
119
143
}
@@ -141,7 +165,11 @@ fn escaping_borrow_of_trait_impl_params_1() {
141
165
fn g < ' a > ( & self , x : usize , y : usize ) -> Box < Fn ( bool ) -> usize + ' a > {
142
166
let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
143
167
//~^ ERROR E0373
168
+ //~| NOTE `x` is borrowed here
169
+ //~| NOTE may outlive borrowed value `x`
144
170
//~| ERROR E0373
171
+ //~| NOTE `y` is borrowed here
172
+ //~| NOTE may outlive borrowed value `y`
145
173
return Box :: new ( f) ;
146
174
}
147
175
}
@@ -156,7 +184,11 @@ fn escaping_borrow_of_trait_impl_params_2() {
156
184
fn g < ' a > ( & self , x : usize , y : usize ) -> Box < Fn ( bool ) -> usize + ' a > {
157
185
let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
158
186
//~^ ERROR E0373
187
+ //~| NOTE `x` is borrowed here
188
+ //~| NOTE may outlive borrowed value `x`
159
189
//~| ERROR E0373
190
+ //~| NOTE `y` is borrowed here
191
+ //~| NOTE may outlive borrowed value `y`
160
192
Box :: new ( f)
161
193
}
162
194
}
@@ -184,7 +216,11 @@ fn escaping_borrow_of_trait_default_params_1() {
184
216
fn g < ' a > ( & self , x : usize , y : usize ) -> Box < Fn ( bool ) -> usize + ' a > {
185
217
let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
186
218
//~^ ERROR E0373
219
+ //~| NOTE `x` is borrowed here
220
+ //~| NOTE may outlive borrowed value `x`
187
221
//~| ERROR E0373
222
+ //~| NOTE `y` is borrowed here
223
+ //~| NOTE may outlive borrowed value `y`
188
224
return Box :: new ( f) ;
189
225
}
190
226
}
@@ -198,7 +234,11 @@ fn escaping_borrow_of_trait_default_params_2() {
198
234
fn g < ' a > ( & self , x : usize , y : usize ) -> Box < Fn ( bool ) -> usize + ' a > {
199
235
let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
200
236
//~^ ERROR E0373
237
+ //~| NOTE `x` is borrowed here
238
+ //~| NOTE may outlive borrowed value `x`
201
239
//~| ERROR E0373
240
+ //~| NOTE `y` is borrowed here
241
+ //~| NOTE may outlive borrowed value `y`
202
242
Box :: new ( f)
203
243
}
204
244
}
0 commit comments