@@ -610,7 +610,8 @@ fn maybe_walk_ty(ty: t, f: fn(t) -> bool) {
610
610
enum fold_mode {
611
611
fm_var( fn @( int ) -> t ) ,
612
612
fm_param( fn @( uint , def_id ) -> t ) ,
613
- fm_rptr( fn @( region , bool /* under & */ ) -> region ) ,
613
+ fm_rptr( fn @( region , bool /* under & */ ) -> region ,
614
+ bool /* descend into outermost fn */ ) ,
614
615
fm_general( fn @( t ) -> t ) ,
615
616
}
616
617
@@ -622,7 +623,7 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
622
623
alt fld {
623
624
fm_var( _) { if !tb. has_vars { ret ty; } }
624
625
fm_param ( _) { if !tb. has_params { ret ty; } }
625
- fm_rptr ( _) { if !tb. has_rptrs { ret ty; } }
626
+ fm_rptr ( _, _ ) { if !tb. has_rptrs { ret ty; } }
626
627
fm_general ( _) { /* no fast path */ }
627
628
}
628
629
@@ -678,22 +679,27 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
678
679
ty = mk_tup ( cx, new_ts) ;
679
680
}
680
681
ty_fn ( f) {
682
+ let mut new_fld;
681
683
alt fld {
682
- fm_rptr( _) {
684
+ fm_rptr( _, false ) {
683
685
// Don't recurse into functions, because regions are
684
686
// universally quantified, well, universally, at function
685
687
// boundaries.
688
+ ret ty;
686
689
}
687
- _ {
688
- let mut new_args : [ arg] = [ ] ;
689
- for a: arg in f. inputs {
690
- let new_ty = do_fold ( cx, fld, a. ty , under_rptr) ;
691
- new_args += [ { mode: a. mode , ty: new_ty} ] ;
692
- }
693
- let new_output = do_fold ( cx, fld, f. output , under_rptr) ;
694
- ty = mk_fn ( cx, { inputs: new_args, output: new_output with f} ) ;
690
+ fm_rptr ( f, true ) {
691
+ new_fld = fm_rptr ( f, false ) ;
695
692
}
693
+ _ { new_fld = fld; }
694
+ }
695
+
696
+ let mut new_args: [ arg ] = [ ] ;
697
+ for a: arg in f. inputs {
698
+ let new_ty = do_fold ( cx, new_fld, a. ty , under_rptr) ;
699
+ new_args += [ { mode: a. mode , ty: new_ty} ] ;
696
700
}
701
+ let new_output = do_fold ( cx, new_fld, f. output , under_rptr) ;
702
+ ty = mk_fn ( cx, { inputs: new_args, output: new_output with f} ) ;
697
703
}
698
704
ty_res ( did, subty, tps) {
699
705
let mut new_tps = [ ] ;
@@ -711,7 +717,7 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
711
717
}
712
718
ty_rptr ( r, tm) {
713
719
let region = alt fld {
714
- fm_rptr( folder) { folder ( r, under_rptr) }
720
+ fm_rptr( folder, _ ) { folder ( r, under_rptr) }
715
721
_ { r }
716
722
} ;
717
723
ty = mk_rptr ( cx, region,
0 commit comments