File tree Expand file tree Collapse file tree 4 files changed +21
-5
lines changed Expand file tree Collapse file tree 4 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -315,7 +315,7 @@ impl<'tcx> LateLintPass<'tcx> for Types {
315
315
fn check_fn (
316
316
& mut self ,
317
317
cx : & LateContext < ' _ > ,
318
- _ : FnKind < ' _ > ,
318
+ fn_kind : FnKind < ' _ > ,
319
319
decl : & FnDecl < ' _ > ,
320
320
_: & Body < ' _ > ,
321
321
_: Span ,
@@ -340,6 +340,7 @@ impl<'tcx> LateLintPass<'tcx> for Types {
340
340
CheckTyContext {
341
341
is_in_trait_impl,
342
342
is_exported,
343
+ in_body : matches ! ( fn_kind, FnKind :: Closure ) ,
343
344
..CheckTyContext :: default ( )
344
345
} ,
345
346
) ;
@@ -427,7 +428,7 @@ impl<'tcx> LateLintPass<'tcx> for Types {
427
428
cx,
428
429
ty,
429
430
CheckTyContext {
430
- is_local : true ,
431
+ in_body : true ,
431
432
..CheckTyContext :: default ( )
432
433
} ,
433
434
) ;
@@ -481,7 +482,7 @@ impl Types {
481
482
}
482
483
483
484
match hir_ty. kind {
484
- TyKind :: Path ( ref qpath) if !context. is_local => {
485
+ TyKind :: Path ( ref qpath) if !context. in_body => {
485
486
let hir_id = hir_ty. hir_id ;
486
487
let res = cx. qpath_res ( qpath, hir_id) ;
487
488
if let Some ( def_id) = res. opt_def_id ( ) {
@@ -581,8 +582,8 @@ impl Types {
581
582
#[ derive( Clone , Copy , Default ) ]
582
583
struct CheckTyContext {
583
584
is_in_trait_impl : bool ,
584
- /// `true` for types on local variables.
585
- is_local : bool ,
585
+ /// `true` for types on local variables and in closure signatures .
586
+ in_body : bool ,
586
587
/// `true` for types that are part of the public API.
587
588
is_exported : bool ,
588
589
is_nested_call : bool ,
Original file line number Diff line number Diff line change @@ -159,4 +159,9 @@ mod box_fat_ptr {
159
159
//~| NOTE: `Box<Box<DynSized>>` is already on the heap, `Rc<Box<Box<DynSized>>>` makes
160
160
}
161
161
162
+ // https://github.com/rust-lang/rust-clippy/issues/11417
163
+ fn type_in_closure ( ) {
164
+ let _ = |_: & mut Box < Box < dyn ToString > > | { } ;
165
+ }
166
+
162
167
fn main ( ) { }
Original file line number Diff line number Diff line change @@ -49,4 +49,9 @@ mod inner_mod {
49
49
}
50
50
}
51
51
52
+ // https://github.com/rust-lang/rust-clippy/issues/11417
53
+ fn in_closure() {
54
+ let _ = |_: Vec<Box<dyn ToString>>| {};
55
+ }
56
+
52
57
fn main() {}
Original file line number Diff line number Diff line change @@ -49,4 +49,9 @@ mod inner_mod {
49
49
}
50
50
}
51
51
52
+ // https://github.com/rust-lang/rust-clippy/issues/11417
53
+ fn in_closure ( ) {
54
+ let _ = |_: Vec < Box < dyn ToString > > | { } ;
55
+ }
56
+
52
57
fn main ( ) { }
You can’t perform that action at this time.
0 commit comments