@@ -58,13 +58,15 @@ use middle::const_eval;
58
58
use middle:: ty:: { arg, field, substs} ;
59
59
use middle:: ty:: { ty_param_substs_and_ty} ;
60
60
use middle:: ty;
61
- use middle:: typeck:: rscope:: { in_binding_rscope} ;
61
+ use middle:: typeck:: rscope:: { in_binding_rscope, in_binding_rscope_ext } ;
62
62
use middle:: typeck:: rscope:: { region_scope, type_rscope, RegionError } ;
63
+ use middle:: typeck:: rscope:: { RegionParamNames } ;
63
64
64
65
use core:: result;
65
66
use core:: vec;
66
67
use syntax:: { ast, ast_util} ;
67
68
use syntax:: codemap:: span;
69
+ use syntax:: opt_vec:: OptVec ;
68
70
use syntax:: print:: pprust:: { lifetime_to_str, path_to_str} ;
69
71
use syntax:: parse:: token:: special_idents;
70
72
use util:: common:: indenter;
@@ -348,9 +350,15 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
348
350
bf. abi , & bf. decl ) )
349
351
}
350
352
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 ,
354
362
ast_ty. span ) ;
355
363
ty:: mk_closure ( tcx, fn_decl)
356
364
}
@@ -507,7 +515,7 @@ pub fn ty_of_bare_fn<AC:AstConv,RS:region_scope + Copy + Durable>(
507
515
abi : ast:: Abi ,
508
516
decl : & ast:: fn_decl )
509
517
-> ty:: BareFnTy {
510
- debug ! ( "ty_of_fn_decl " ) ;
518
+ debug ! ( "ty_of_bare_fn " ) ;
511
519
512
520
// new region names that appear inside of the fn decl are bound to
513
521
// that function type
@@ -526,6 +534,33 @@ pub fn ty_of_bare_fn<AC:AstConv,RS:region_scope + Copy + Durable>(
526
534
}
527
535
}
528
536
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
+
529
564
pub fn ty_of_closure < AC : AstConv , RS : region_scope + Copy + Durable > (
530
565
self : & AC ,
531
566
rscope : & RS ,
@@ -535,6 +570,7 @@ pub fn ty_of_closure<AC:AstConv,RS:region_scope + Copy + Durable>(
535
570
opt_lifetime : Option < @ast:: Lifetime > ,
536
571
decl : & ast:: fn_decl ,
537
572
expected_tys : Option < ty:: FnSig > ,
573
+ lifetimes : & OptVec < ast:: Lifetime > ,
538
574
span : span )
539
575
-> ty:: ClosureTy {
540
576
debug ! ( "ty_of_fn_decl" ) ;
@@ -563,7 +599,8 @@ pub fn ty_of_closure<AC:AstConv,RS:region_scope + Copy + Durable>(
563
599
564
600
// new region names that appear inside of the fn decl are bound to
565
601
// 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) ;
567
604
568
605
let input_tys = do decl. inputs . mapi |i, a| {
569
606
let expected_arg_ty = do expected_tys. chain_ref |e| {
0 commit comments