@@ -201,7 +201,7 @@ enum SelectionCandidate<'tcx> {
201201
202202 /// Implementation of a `Fn`-family trait by one of the
203203 /// anonymous types generated for a `||` expression.
204- ClosureCandidate ( /* closure */ ast:: DefId , Substs < ' tcx > ) ,
204+ ClosureCandidate ( /* closure */ ast:: DefId , & ' tcx Substs < ' tcx > , & ' tcx Vec < Ty < ' tcx > > ) ,
205205
206206 /// Implementation of a `Fn`-family trait by one of the anonymous
207207 /// types generated for a fn pointer type (e.g., `fn(int)->int`)
@@ -348,7 +348,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
348348 // lifetimes can appear inside the self-type.
349349 let self_ty = self . infcx . shallow_resolve ( * obligation. self_ty ( ) . skip_binder ( ) ) ;
350350 let ( closure_def_id, substs) = match self_ty. sty {
351- ty:: TyClosure ( id, ref substs) => ( id, substs. clone ( ) ) ,
351+ ty:: TyClosure ( id, ref substs, _ ) => ( id, substs. clone ( ) ) ,
352352 _ => { return ; }
353353 } ;
354354 assert ! ( !substs. has_escaping_regions( ) ) ;
@@ -1142,8 +1142,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11421142 // touch bound regions, they just capture the in-scope
11431143 // type/region parameters
11441144 let self_ty = self . infcx . shallow_resolve ( * obligation. self_ty ( ) . skip_binder ( ) ) ;
1145- let ( closure_def_id, substs) = match self_ty. sty {
1146- ty:: TyClosure ( id, substs) => ( id, substs) ,
1145+ let ( closure_def_id, substs, upvar_tys ) = match self_ty. sty {
1146+ ty:: TyClosure ( id, substs, ref upvar_tys ) => ( id, substs, upvar_tys ) ,
11471147 ty:: TyInfer ( ty:: TyVar ( _) ) => {
11481148 debug ! ( "assemble_unboxed_closure_candidates: ambiguous self-type" ) ;
11491149 candidates. ambiguous = true ;
@@ -1161,8 +1161,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11611161 Some ( closure_kind) => {
11621162 debug ! ( "assemble_unboxed_candidates: closure_kind = {:?}" , closure_kind) ;
11631163 if closure_kind. extends ( kind) {
1164- candidates. vec . push ( ClosureCandidate ( closure_def_id,
1165- substs. clone ( ) ) ) ;
1164+ candidates. vec . push ( ClosureCandidate ( closure_def_id, substs, upvar_tys) ) ;
11661165 }
11671166 }
11681167 None => {
@@ -1704,7 +1703,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
17041703 // (T1, ..., Tn) -- meets any bound that all of T1...Tn meet
17051704 ty:: TyTuple ( ref tys) => ok_if ( tys. clone ( ) ) ,
17061705
1707- ty:: TyClosure ( def_id, substs) => {
1706+ ty:: TyClosure ( def_id, substs, _ ) => {
17081707 // FIXME -- This case is tricky. In the case of by-ref
17091708 // closures particularly, we need the results of
17101709 // inference to decide how to reflect the type of each
@@ -1730,6 +1729,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
17301729 return ok_if ( Vec :: new ( ) ) ;
17311730 }
17321731
1732+ // TODO
17331733 match self . infcx . closure_upvars ( def_id, substs) {
17341734 Some ( upvars) => ok_if ( upvars. iter ( ) . map ( |c| c. ty ) . collect ( ) ) ,
17351735 None => {
@@ -1865,9 +1865,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
18651865 Some ( tys. clone ( ) )
18661866 }
18671867
1868- ty:: TyClosure ( def_id, substs) => {
1868+ ty:: TyClosure ( def_id, substs, _ ) => {
18691869 assert_eq ! ( def_id. krate, ast:: LOCAL_CRATE ) ;
18701870
1871+ // TODO
18711872 match self . infcx . closure_upvars ( def_id, substs) {
18721873 Some ( upvars) => {
18731874 Some ( upvars. iter ( ) . map ( |c| c. ty ) . collect ( ) )
@@ -2014,9 +2015,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
20142015 Ok ( VtableImpl ( vtable_impl) )
20152016 }
20162017
2017- ClosureCandidate ( closure_def_id, substs) => {
2018+ ClosureCandidate ( closure_def_id, substs, upvar_tys ) => {
20182019 let vtable_closure =
2019- try!( self . confirm_closure_candidate ( obligation, closure_def_id, & substs) ) ;
2020+ try!( self . confirm_closure_candidate ( obligation, closure_def_id,
2021+ & substs, upvar_tys) ) ;
20202022 Ok ( VtableClosure ( vtable_closure) )
20212023 }
20222024
@@ -2365,7 +2367,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
23652367 fn confirm_closure_candidate ( & mut self ,
23662368 obligation : & TraitObligation < ' tcx > ,
23672369 closure_def_id : ast:: DefId ,
2368- substs : & Substs < ' tcx > )
2370+ substs : & Substs < ' tcx > ,
2371+ upvar_tys : & ' tcx Vec < Ty < ' tcx > > )
23692372 -> Result < VtableClosureData < ' tcx , PredicateObligation < ' tcx > > ,
23702373 SelectionError < ' tcx > >
23712374 {
@@ -2391,6 +2394,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
23912394 Ok ( VtableClosureData {
23922395 closure_def_id : closure_def_id,
23932396 substs : substs. clone ( ) ,
2397+ upvar_tys : upvar_tys. clone ( ) ,
23942398 nested : obligations
23952399 } )
23962400 }
0 commit comments