1616
1717fn escaping_borrow_of_closure_params_1 ( ) {
1818 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
1923 let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
2024 //~^ ERROR `x` does not live long enough
2125 //~| ERROR `y` does not live long enough
@@ -31,6 +35,10 @@ fn escaping_borrow_of_closure_params_1() {
3135
3236fn escaping_borrow_of_closure_params_2 ( ) {
3337 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
3442 let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
3543 //~^ ERROR `x` does not live long enough
3644 //~| ERROR `y` does not live long enough
@@ -64,7 +72,11 @@ fn escaping_borrow_of_fn_params_1() {
6472 fn g < ' a > ( x : usize , y : usize ) -> Box < Fn ( bool ) -> usize + ' a > {
6573 let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
6674 //~^ ERROR E0373
75+ //~| NOTE `x` is borrowed here
76+ //~| NOTE may outlive borrowed value `x`
6777 //~| ERROR E0373
78+ //~| NOTE `y` is borrowed here
79+ //~| NOTE may outlive borrowed value `y`
6880 return Box :: new ( f) ;
6981 } ;
7082
@@ -75,7 +87,11 @@ fn escaping_borrow_of_fn_params_2() {
7587 fn g < ' a > ( x : usize , y : usize ) -> Box < Fn ( bool ) -> usize + ' a > {
7688 let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
7789 //~^ ERROR E0373
90+ //~| NOTE `x` is borrowed here
91+ //~| NOTE may outlive borrowed value `x`
7892 //~| ERROR E0373
93+ //~| NOTE `y` is borrowed here
94+ //~| NOTE may outlive borrowed value `y`
7995 Box :: new ( f)
8096 } ;
8197
@@ -99,7 +115,11 @@ fn escaping_borrow_of_method_params_1() {
99115 fn g < ' a > ( & self , x : usize , y : usize ) -> Box < Fn ( bool ) -> usize + ' a > {
100116 let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
101117 //~^ ERROR E0373
118+ //~| NOTE `x` is borrowed here
119+ //~| NOTE may outlive borrowed value `x`
102120 //~| ERROR E0373
121+ //~| NOTE `y` is borrowed here
122+ //~| NOTE may outlive borrowed value `y`
103123 return Box :: new ( f) ;
104124 }
105125 }
@@ -113,7 +133,11 @@ fn escaping_borrow_of_method_params_2() {
113133 fn g < ' a > ( & self , x : usize , y : usize ) -> Box < Fn ( bool ) -> usize + ' a > {
114134 let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
115135 //~^ ERROR E0373
136+ //~| NOTE `x` is borrowed here
137+ //~| NOTE may outlive borrowed value `x`
116138 //~| ERROR E0373
139+ //~| NOTE `y` is borrowed here
140+ //~| NOTE may outlive borrowed value `y`
117141 Box :: new ( f)
118142 }
119143 }
@@ -141,7 +165,11 @@ fn escaping_borrow_of_trait_impl_params_1() {
141165 fn g < ' a > ( & self , x : usize , y : usize ) -> Box < Fn ( bool ) -> usize + ' a > {
142166 let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
143167 //~^ ERROR E0373
168+ //~| NOTE `x` is borrowed here
169+ //~| NOTE may outlive borrowed value `x`
144170 //~| ERROR E0373
171+ //~| NOTE `y` is borrowed here
172+ //~| NOTE may outlive borrowed value `y`
145173 return Box :: new ( f) ;
146174 }
147175 }
@@ -156,7 +184,11 @@ fn escaping_borrow_of_trait_impl_params_2() {
156184 fn g < ' a > ( & self , x : usize , y : usize ) -> Box < Fn ( bool ) -> usize + ' a > {
157185 let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
158186 //~^ ERROR E0373
187+ //~| NOTE `x` is borrowed here
188+ //~| NOTE may outlive borrowed value `x`
159189 //~| ERROR E0373
190+ //~| NOTE `y` is borrowed here
191+ //~| NOTE may outlive borrowed value `y`
160192 Box :: new ( f)
161193 }
162194 }
@@ -184,7 +216,11 @@ fn escaping_borrow_of_trait_default_params_1() {
184216 fn g < ' a > ( & self , x : usize , y : usize ) -> Box < Fn ( bool ) -> usize + ' a > {
185217 let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
186218 //~^ ERROR E0373
219+ //~| NOTE `x` is borrowed here
220+ //~| NOTE may outlive borrowed value `x`
187221 //~| ERROR E0373
222+ //~| NOTE `y` is borrowed here
223+ //~| NOTE may outlive borrowed value `y`
188224 return Box :: new ( f) ;
189225 }
190226 }
@@ -198,7 +234,11 @@ fn escaping_borrow_of_trait_default_params_2() {
198234 fn g < ' a > ( & self , x : usize , y : usize ) -> Box < Fn ( bool ) -> usize + ' a > {
199235 let f = |t : bool | if t { x } else { y } ; // (separate errors for `x` vs `y`)
200236 //~^ ERROR E0373
237+ //~| NOTE `x` is borrowed here
238+ //~| NOTE may outlive borrowed value `x`
201239 //~| ERROR E0373
240+ //~| NOTE `y` is borrowed here
241+ //~| NOTE may outlive borrowed value `y`
202242 Box :: new ( f)
203243 }
204244 }
0 commit comments