This repository was archived by the owner on May 28, 2025. It is now read-only.
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 {
315315 fn check_fn (
316316 & mut self ,
317317 cx : & LateContext < ' _ > ,
318- _ : FnKind < ' _ > ,
318+ fn_kind : FnKind < ' _ > ,
319319 decl : & FnDecl < ' _ > ,
320320 _: & Body < ' _ > ,
321321 _: Span ,
@@ -340,6 +340,7 @@ impl<'tcx> LateLintPass<'tcx> for Types {
340340 CheckTyContext {
341341 is_in_trait_impl,
342342 is_exported,
343+ in_body : matches ! ( fn_kind, FnKind :: Closure ) ,
343344 ..CheckTyContext :: default ( )
344345 } ,
345346 ) ;
@@ -427,7 +428,7 @@ impl<'tcx> LateLintPass<'tcx> for Types {
427428 cx,
428429 ty,
429430 CheckTyContext {
430- is_local : true ,
431+ in_body : true ,
431432 ..CheckTyContext :: default ( )
432433 } ,
433434 ) ;
@@ -481,7 +482,7 @@ impl Types {
481482 }
482483
483484 match hir_ty. kind {
484- TyKind :: Path ( ref qpath) if !context. is_local => {
485+ TyKind :: Path ( ref qpath) if !context. in_body => {
485486 let hir_id = hir_ty. hir_id ;
486487 let res = cx. qpath_res ( qpath, hir_id) ;
487488 if let Some ( def_id) = res. opt_def_id ( ) {
@@ -581,8 +582,8 @@ impl Types {
581582#[ derive( Clone , Copy , Default ) ]
582583struct CheckTyContext {
583584 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 ,
586587 /// `true` for types that are part of the public API.
587588 is_exported : bool ,
588589 is_nested_call : bool ,
Original file line number Diff line number Diff line change @@ -159,4 +159,9 @@ mod box_fat_ptr {
159159 //~| NOTE: `Box<Box<DynSized>>` is already on the heap, `Rc<Box<Box<DynSized>>>` makes
160160}
161161
162+ // https://github.com/rust-lang/rust-clippy/issues/11417
163+ fn type_in_closure ( ) {
164+ let _ = |_: & mut Box < Box < dyn ToString > > | { } ;
165+ }
166+
162167fn main ( ) { }
Original file line number Diff line number Diff line change @@ -49,4 +49,9 @@ mod inner_mod {
4949 }
5050}
5151
52+ // https://github.com/rust-lang/rust-clippy/issues/11417
53+ fn in_closure() {
54+ let _ = |_: Vec<Box<dyn ToString>>| {};
55+ }
56+
5257fn main() {}
Original file line number Diff line number Diff line change @@ -49,4 +49,9 @@ mod inner_mod {
4949 }
5050}
5151
52+ // https://github.com/rust-lang/rust-clippy/issues/11417
53+ fn in_closure ( ) {
54+ let _ = |_: Vec < Box < dyn ToString > > | { } ;
55+ }
56+
5257fn main ( ) { }
You can’t perform that action at this time.
0 commit comments