File tree 3 files changed +39
-1
lines changed 3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -300,3 +300,16 @@ mod meets_msrv {
300
300
let _ = std::process::Command::new("ls").args(["-a", "-l"]).status().unwrap();
301
301
}
302
302
}
303
+
304
+ #[allow(dead_code)]
305
+ fn closure_test() {
306
+ let env = "env".to_owned();
307
+ let arg = "arg".to_owned();
308
+ let f = |arg| {
309
+ let loc = "loc".to_owned();
310
+ let _ = std::fs::write("x", &env); // Don't lint. In environment
311
+ let _ = std::fs::write("x", arg);
312
+ let _ = std::fs::write("x", loc);
313
+ };
314
+ f(arg);
315
+ }
Original file line number Diff line number Diff line change @@ -300,3 +300,16 @@ mod meets_msrv {
300
300
let _ = std:: process:: Command :: new ( "ls" ) . args ( & [ "-a" , "-l" ] ) . status ( ) . unwrap ( ) ;
301
301
}
302
302
}
303
+
304
+ #[ allow( dead_code) ]
305
+ fn closure_test ( ) {
306
+ let env = "env" . to_owned ( ) ;
307
+ let arg = "arg" . to_owned ( ) ;
308
+ let f = |arg| {
309
+ let loc = "loc" . to_owned ( ) ;
310
+ let _ = std:: fs:: write ( "x" , & env) ; // Don't lint. In environment
311
+ let _ = std:: fs:: write ( "x" , & arg) ;
312
+ let _ = std:: fs:: write ( "x" , & loc) ;
313
+ } ;
314
+ f ( arg) ;
315
+ }
Original file line number Diff line number Diff line change @@ -186,5 +186,17 @@ 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:311: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:312:37
197
+ |
198
+ LL | let _ = std::fs::write("x", &loc);
199
+ | ^^^^ help: change this to: `loc`
200
+
201
+ error: aborting due to 33 previous errors
190
202
You can’t perform that action at this time.
0 commit comments