Skip to content

Commit 3c398d2

Browse files
committed
rustc: Universally quantify regions when calling functions. Un-XFAIL regions-addr-of-ret.rs.
1 parent ca6636d commit 3c398d2

File tree

4 files changed

+106
-120
lines changed

4 files changed

+106
-120
lines changed

src/rustc/middle/infer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ impl resolve_methods for infer_ctxt {
834834
}
835835
_ { region }
836836
}
837-
}), typ);
837+
}, false), typ);
838838

839839
let ur = *unresolved;
840840
alt ur {

src/rustc/middle/ty.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,8 @@ fn maybe_walk_ty(ty: t, f: fn(t) -> bool) {
610610
enum fold_mode {
611611
fm_var(fn@(int) -> t),
612612
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 */),
614615
fm_general(fn@(t) -> t),
615616
}
616617

@@ -622,7 +623,7 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
622623
alt fld {
623624
fm_var(_) { if !tb.has_vars { ret ty; } }
624625
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; } }
626627
fm_general(_) {/* no fast path */ }
627628
}
628629

@@ -678,22 +679,27 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
678679
ty = mk_tup(cx, new_ts);
679680
}
680681
ty_fn(f) {
682+
let mut new_fld;
681683
alt fld {
682-
fm_rptr(_) {
684+
fm_rptr(_, false) {
683685
// Don't recurse into functions, because regions are
684686
// universally quantified, well, universally, at function
685687
// boundaries.
688+
ret ty;
686689
}
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);
695692
}
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}];
696700
}
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});
697703
}
698704
ty_res(did, subty, tps) {
699705
let mut new_tps = [];
@@ -711,7 +717,7 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
711717
}
712718
ty_rptr(r, tm) {
713719
let region = alt fld {
714-
fm_rptr(folder) { folder(r, under_rptr) }
720+
fm_rptr(folder, _) { folder(r, under_rptr) }
715721
_ { r }
716722
};
717723
ty = mk_rptr(cx, region,

0 commit comments

Comments
 (0)