File tree 3 files changed +45
-1
lines changed 3 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -329,3 +329,16 @@ fn issue9383() {
329
329
ManuallyDrop::drop(&mut ocean.coral);
330
330
}
331
331
}
332
+
333
+ #[allow(dead_code)]
334
+ fn closure_test() {
335
+ let env = "env".to_owned();
336
+ let arg = "arg".to_owned();
337
+ let f = |arg| {
338
+ let loc = "loc".to_owned();
339
+ let _ = std::fs::write("x", &env); // Don't lint. In environment
340
+ let _ = std::fs::write("x", arg);
341
+ let _ = std::fs::write("x", loc);
342
+ };
343
+ f(arg);
344
+ }
Original file line number Diff line number Diff line change @@ -329,3 +329,16 @@ fn issue9383() {
329
329
ManuallyDrop :: drop ( & mut ocean. coral ) ;
330
330
}
331
331
}
332
+
333
+ #[ allow( dead_code) ]
334
+ fn closure_test ( ) {
335
+ let env = "env" . to_owned ( ) ;
336
+ let arg = "arg" . to_owned ( ) ;
337
+ let f = |arg| {
338
+ let loc = "loc" . to_owned ( ) ;
339
+ let _ = std:: fs:: write ( "x" , & env) ; // Don't lint. In environment
340
+ let _ = std:: fs:: write ( "x" , & arg) ;
341
+ let _ = std:: fs:: write ( "x" , & loc) ;
342
+ } ;
343
+ f ( arg) ;
344
+ }
Original file line number Diff line number Diff line change @@ -186,5 +186,23 @@ error: the borrowed expression implements the required traits
186
186
LL | let _ = std::process::Command::new("ls").args(&["-a", "-l"]).status().unwrap();
187
187
| ^^^^^^^^^^^^^ help: change this to: `["-a", "-l"]`
188
188
189
- error: aborting due to 31 previous errors
189
+ error: the borrowed expression implements the required traits
190
+ --> $DIR/needless_borrow.rs:340:37
191
+ |
192
+ LL | let _ = std::fs::write("x", &arg);
193
+ | ^^^^ help: change this to: `arg`
194
+
195
+ error: the borrowed expression implements the required traits
196
+ --> $DIR/needless_borrow.rs:341:37
197
+ |
198
+ LL | let _ = std::fs::write("x", &loc);
199
+ | ^^^^ help: change this to: `loc`
200
+
201
+ error: the borrowed expression implements the required traits
202
+ --> $DIR/needless_borrow.rs:360:15
203
+ |
204
+ LL | debug(&x);
205
+ | ^^ help: change this to: `x`
206
+
207
+ error: aborting due to 34 previous errors
190
208
You can’t perform that action at this time.
0 commit comments