@@ -11,11 +11,11 @@ use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
1111use rustc_infer:: infer:: { BoundRegionConversionTime , DefineOpaqueTypes , InferOk , InferResult } ;
1212use rustc_infer:: traits:: { ObligationCauseCode , PredicateObligations } ;
1313use rustc_macros:: { TypeFoldable , TypeVisitable } ;
14- use rustc_middle:: span_bug;
1514use rustc_middle:: ty:: {
1615 self , ClosureKind , GenericArgs , Ty , TyCtxt , TypeSuperVisitable , TypeVisitable ,
1716 TypeVisitableExt , TypeVisitor ,
1817} ;
18+ use rustc_middle:: { bug, span_bug} ;
1919use rustc_span:: def_id:: LocalDefId ;
2020use rustc_span:: { DUMMY_SP , Span } ;
2121use rustc_trait_selection:: error_reporting:: traits:: ArgKind ;
@@ -340,6 +340,37 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
340340 ( None , None )
341341 }
342342 } ,
343+ ty:: Closure ( _, args) => match closure_kind {
344+ hir:: ClosureKind :: Closure => {
345+ let closure_args = args. as_closure ( ) ;
346+ let sig = closure_args. sig ( ) ;
347+ tracing:: debug!( ?closure_args, ?sig) ;
348+ let sig = sig. map_bound ( |sig| {
349+ let inputs = sig. inputs_and_output . first ( ) . unwrap ( ) ;
350+ let inputs = match inputs. kind ( ) {
351+ ty:: Tuple ( tys) => tys,
352+ _ => bug ! ( ) ,
353+ } ;
354+ let output = sig. inputs_and_output . last ( ) . unwrap ( ) ;
355+ let inputs_and_output = self . tcx . mk_type_list (
356+ & inputs. iter ( ) . chain ( [ * output] ) . collect :: < smallvec:: SmallVec < [ _ ; 4 ] > > ( ) ,
357+ ) ;
358+ ty:: FnSig {
359+ abi : sig. abi ,
360+ safety : sig. safety ,
361+ c_variadic : sig. c_variadic ,
362+ inputs_and_output,
363+ }
364+ } ) ;
365+ tracing:: debug!( ?sig) ;
366+ let expected_sig = ExpectedSig { cause_span : None , sig } ;
367+ let kind = closure_args. kind_ty ( ) . to_opt_closure_kind ( ) ;
368+ ( Some ( expected_sig) , kind)
369+ }
370+ hir:: ClosureKind :: Coroutine ( _) | hir:: ClosureKind :: CoroutineClosure ( _) => {
371+ ( None , None )
372+ }
373+ } ,
343374 _ => ( None , None ) ,
344375 }
345376 }
0 commit comments