@@ -58,13 +58,15 @@ use middle::const_eval;
5858use middle:: ty:: { arg, field, substs} ;
5959use middle:: ty:: { ty_param_substs_and_ty} ;
6060use middle:: ty;
61- use middle:: typeck:: rscope:: { in_binding_rscope} ;
61+ use middle:: typeck:: rscope:: { in_binding_rscope, in_binding_rscope_ext } ;
6262use middle:: typeck:: rscope:: { region_scope, type_rscope, RegionError } ;
63+ use middle:: typeck:: rscope:: { RegionParamNames } ;
6364
6465use core:: result;
6566use core:: vec;
6667use syntax:: { ast, ast_util} ;
6768use syntax:: codemap:: span;
69+ use syntax:: opt_vec:: OptVec ;
6870use syntax:: print:: pprust:: { lifetime_to_str, path_to_str} ;
6971use syntax:: parse:: token:: special_idents;
7072use util:: common:: indenter;
@@ -348,9 +350,15 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
348350 bf. abi , & bf. decl ) )
349351 }
350352 ast:: ty_closure( ref f) => {
351- let fn_decl = ty_of_closure ( self , rscope, f. sigil ,
352- f. purity , f. onceness ,
353- f. region , & f. decl , None ,
353+ let fn_decl = ty_of_closure ( self ,
354+ rscope,
355+ f. sigil ,
356+ f. purity ,
357+ f. onceness ,
358+ f. region ,
359+ & f. decl ,
360+ None ,
361+ & f. lifetimes ,
354362 ast_ty. span ) ;
355363 ty:: mk_closure ( tcx, fn_decl)
356364 }
@@ -507,7 +515,7 @@ pub fn ty_of_bare_fn<AC:AstConv,RS:region_scope + Copy + Durable>(
507515 abi : ast:: Abi ,
508516 decl : & ast:: fn_decl )
509517 -> ty:: BareFnTy {
510- debug ! ( "ty_of_fn_decl " ) ;
518+ debug ! ( "ty_of_bare_fn " ) ;
511519
512520 // new region names that appear inside of the fn decl are bound to
513521 // that function type
@@ -526,6 +534,33 @@ pub fn ty_of_bare_fn<AC:AstConv,RS:region_scope + Copy + Durable>(
526534 }
527535}
528536
537+ pub fn ty_of_bare_fn_ext < AC : AstConv , RS : region_scope + Copy + Durable > (
538+ self : & AC ,
539+ rscope : & RS ,
540+ purity : ast:: purity ,
541+ abi : ast:: Abi ,
542+ decl : & ast:: fn_decl ,
543+ +region_param_names : RegionParamNames )
544+ -> ty:: BareFnTy {
545+ debug ! ( "ty_of_bare_fn_ext" ) ;
546+
547+ // new region names that appear inside of the fn decl are bound to
548+ // that function type
549+ let rb = in_binding_rscope_ext ( rscope, region_param_names) ;
550+
551+ let input_tys = decl. inputs . map ( |a| ty_of_arg ( self , & rb, * a, None ) ) ;
552+ let output_ty = match decl. output . node {
553+ ast:: ty_infer => self . ty_infer ( decl. output . span ) ,
554+ _ => ast_ty_to_ty ( self , & rb, decl. output )
555+ } ;
556+
557+ ty:: BareFnTy {
558+ purity : purity,
559+ abi : abi,
560+ sig : ty:: FnSig { inputs : input_tys, output : output_ty}
561+ }
562+ }
563+
529564pub fn ty_of_closure < AC : AstConv , RS : region_scope + Copy + Durable > (
530565 self : & AC ,
531566 rscope : & RS ,
@@ -535,6 +570,7 @@ pub fn ty_of_closure<AC:AstConv,RS:region_scope + Copy + Durable>(
535570 opt_lifetime : Option < @ast:: Lifetime > ,
536571 decl : & ast:: fn_decl ,
537572 expected_tys : Option < ty:: FnSig > ,
573+ lifetimes : & OptVec < ast:: Lifetime > ,
538574 span : span )
539575 -> ty:: ClosureTy {
540576 debug ! ( "ty_of_fn_decl" ) ;
@@ -563,7 +599,8 @@ pub fn ty_of_closure<AC:AstConv,RS:region_scope + Copy + Durable>(
563599
564600 // new region names that appear inside of the fn decl are bound to
565601 // that function type
566- let rb = in_binding_rscope ( rscope) ;
602+ let region_param_names = RegionParamNames :: from_lifetimes ( lifetimes) ;
603+ let rb = in_binding_rscope_ext ( rscope, region_param_names) ;
567604
568605 let input_tys = do decl. inputs . mapi |i, a| {
569606 let expected_arg_ty = do expected_tys. chain_ref |e| {
0 commit comments