Skip to content

Commit c56910f

Browse files
committed
rustc: Make region folding not descend into function types
Since region parameters are always universally quantified at the function level, this would be incorrect.
1 parent 1ffaeda commit c56910f

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/rustc/middle/ty.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -666,14 +666,22 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
666666
ty = mk_tup(cx, new_ts);
667667
}
668668
ty_fn(f) {
669-
let mut new_args: [arg] = [];
670-
for a: arg in f.inputs {
671-
let new_ty = do_fold(cx, fld, a.ty, under_rptr);
672-
new_args += [{mode: a.mode, ty: new_ty}];
669+
alt fld {
670+
fm_rptr(_) {
671+
// Don't recurse into functions, because regions are
672+
// universally quantified, well, universally, at function
673+
// boundaries.
674+
}
675+
_ {
676+
let mut new_args: [arg] = [];
677+
for a: arg in f.inputs {
678+
let new_ty = do_fold(cx, fld, a.ty, under_rptr);
679+
new_args += [{mode: a.mode, ty: new_ty}];
680+
}
681+
let new_output = do_fold(cx, fld, f.output, under_rptr);
682+
ty = mk_fn(cx, {inputs: new_args, output: new_output with f});
683+
}
673684
}
674-
ty = mk_fn(cx, {inputs: new_args,
675-
output: do_fold(cx, fld, f.output, under_rptr)
676-
with f});
677685
}
678686
ty_res(did, subty, tps) {
679687
let mut new_tps = [];

0 commit comments

Comments
 (0)