Skip to content

Commit 407be52

Browse files
committed
rustc: Generalize resolve_var to work with regions too
1 parent a5d5063 commit 407be52

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/rustc/middle/infer.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ impl of to_str for ty::mt {
105105
}
106106
}
107107

108+
impl of to_str for ty::region {
109+
fn to_str(cx: infer_ctxt) -> str {
110+
util::ppaux::region_to_str(cx.tcx, self)
111+
}
112+
}
113+
108114
impl<V:copy to_str> of to_str for bound<V> {
109115
fn to_str(cx: infer_ctxt) -> str {
110116
alt self {
@@ -756,11 +762,15 @@ impl resolve_methods for infer_ctxt {
756762
ret self.resolve_var(self.vb, {|t| type_is_bot(t)}, vid);
757763
}
758764

765+
fn resolve_region_var(rid: int) -> fres<ty::region> {
766+
ret self.resolve_var(self.rb, {|_t| false}, rid);
767+
}
768+
759769
fn resolve_ty(typ: ty::t) -> fres<ty::t> {
760770
alt ty::get(typ).struct {
761771
ty::ty_var(vid) { self.resolve_ty_var(vid) }
762772
ty::ty_rptr(ty::re_var(rid), base_ty) {
763-
alt self.resolve_region(rid as int) {
773+
alt self.resolve_region_var(rid as int) {
764774
err(terr) { err(terr) }
765775
ok(region) {
766776
self.rok(ty::mk_rptr(self.tcx, region, base_ty))
@@ -825,25 +835,12 @@ impl resolve_methods for infer_ctxt {
825835
// FIXME: These should be integrated with the two functions above instead
826836
// of being such blatant lazy duplicates.
827837

828-
fn resolve_region(rid: int) -> fres<ty::region> {
829-
let {root:_, bounds} = self.get_region(rid as uint);
830-
831-
// See comments in resolve_ty above re. nonobviousness.
832-
833-
alt bounds {
834-
{ ub:_, lb:some(r) } |
835-
{ ub:some(r), lb:_ } |
836-
{ ub:_, lb:some(r) } { ok(r) }
837-
{ ub:none, lb:none } { self.rerr(rid) }
838-
}
839-
}
840-
841838
fn subst_regions(unresolved: @mutable option<int>,
842839
regions_seen: std::list::list<int>,
843840
rid: int) -> ty::region {
844841
// Should really return a fixup_result instead of a t, but fold_ty
845842
// doesn't allow returning anything but a t.
846-
alt self.resolve_region(rid) {
843+
alt self.resolve_region_var(rid) {
847844
err(rid) {
848845
*unresolved = some(rid);
849846
ret ty::re_var(rid as uint);

0 commit comments

Comments
 (0)