Skip to content

Commit bc7395d

Browse files
committed
---
yaml --- r: 12022 b: refs/heads/master c: 68e364b h: refs/heads/master v: v3
1 parent 5ec9b97 commit bc7395d

File tree

6 files changed

+37
-18
lines changed

6 files changed

+37
-18
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 071dedde79137bbc24b19034df117810785f2301
2+
refs/heads/master: 68e364b54d8caad98d69679a8e4d1cee8d6607c5
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustc/metadata/tyencode.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ fn enc_region(w: io::writer, cx: @ctxt, r: ty::region) {
106106
ty::re_self(did) {
107107
w.write_char('s'); w.write_str(cx.ds(did)); w.write_char('|');
108108
}
109-
ty::re_inferred { w.write_char('?'); }
109+
ty::re_param(id) {
110+
w.write_char('p'); w.write_uint(id); w.write_char('|');
111+
}
110112
}
111113
}
112114
fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {

trunk/src/rustc/middle/region.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ fn region_to_scope(region_map: @region_map, region: ty::region)
8080
ty::re_caller(def_id) | ty::re_self(def_id) { def_id.node }
8181
ty::re_named(def_id) { region_map.region_name_to_fn.get(def_id) }
8282
ty::re_block(node_id) { node_id }
83-
ty::re_inferred { fail "unresolved region in region_to_scope" }
83+
ty::re_param(_) { fail "unresolved region in region_to_scope" }
8484
};
8585
}
8686

@@ -109,7 +109,7 @@ fn get_inferred_region(cx: ctxt, sp: syntax::codemap::span) -> ty::region {
109109
ty::re_caller({crate: ast::local_crate, node: item_id})
110110
}
111111
pa_block(block_id) { ty::re_block(block_id) }
112-
pa_item(_) { ty::re_inferred }
112+
pa_item(_) { ty::re_param(0u) }
113113
pa_crate { cx.sess.span_bug(sp, "inferred region at crate level?!"); }
114114
}
115115
}

trunk/src/rustc/middle/regionck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn check_expr(expr: @ast::expr, cx: ctxt, visitor: visit::vt<ctxt>) {
5151
"escapes its block");
5252
}
5353
}
54-
ty::re_inferred {
54+
ty::re_param(_) {
5555
cx.tcx.sess.span_bug(expr.span,
5656
"unresolved region");
5757
}

trunk/src/rustc/middle/ty.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export ty_uint, mk_uint, mk_mach_uint;
8989
export ty_uniq, mk_uniq, mk_imm_uniq, type_is_unique_box;
9090
export ty_var, mk_var;
9191
export ty_self, mk_self;
92-
export region, re_named, re_caller, re_block, re_inferred;
92+
export region, re_named, re_caller, re_block, re_param;
9393
export get, type_has_params, type_has_vars, type_has_rptrs, type_id;
9494
export same_type;
9595
export ty_var_id;
@@ -242,7 +242,10 @@ enum region {
242242
re_caller(def_id),
243243
re_self(def_id),
244244
re_block(node_id),
245-
re_inferred /* currently unresolved (for typedefs) */
245+
246+
// A region parameter. Currently used only for typedefs.
247+
// TODO: Use this for caller and named regions as well.
248+
re_param(uint)
246249
}
247250

248251
// NB: If you change this, you'll probably want to change the corresponding
@@ -1163,7 +1166,7 @@ fn hash_type_structure(st: sty) -> uint {
11631166
re_caller(_) { 2u }
11641167
re_self(_) { 3u }
11651168
re_block(_) { 4u }
1166-
re_inferred { 5u }
1169+
re_param(_) { 5u }
11671170
}
11681171
}
11691172
alt st {
@@ -1928,12 +1931,17 @@ mod unify {
19281931
}
19291932
}
19301933

1931-
if sub == ty::re_inferred || super == ty::re_inferred {
1932-
ret if sub == super {
1933-
nxt(super)
1934-
} else {
1935-
err(terr_regions_differ(true, super, sub))
1936-
};
1934+
// FIXME: This is wrong. We should be keeping a set of region bindings
1935+
// around.
1936+
alt (sub, super) {
1937+
(ty::re_param(_), _) | (_, ty::re_param(_)) {
1938+
ret if sub == super {
1939+
nxt(super)
1940+
} else {
1941+
err(terr_regions_differ(true, super, sub))
1942+
}
1943+
}
1944+
_ { /* fall through */ }
19371945
}
19381946

19391947
// Outer regions are subtypes of inner regions. (This is somewhat

trunk/src/rustc/middle/typeck.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
256256
ty: ty::t) -> ty::t {
257257
ret ty::fold_ty(tcx, ty::fm_rptr({|r|
258258
alt r {
259-
ty::re_inferred | ty::re_self(_) {
259+
// FIXME: This is probably wrong for params.
260+
ty::re_param(_) | ty::re_self(_) {
260261
tcx.region_map.ast_type_to_inferred_region.get(use_site)
261262
}
262263
_ { r }
@@ -356,7 +357,11 @@ fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
356357
let attir = tcx.region_map.ast_type_to_inferred_region;
357358
alt attir.find(ast_ty.id) {
358359
some(resolved_region) { resolved_region }
359-
none { ty::re_inferred }
360+
none {
361+
// FIXME: Shouldn't be 0u and should instead be
362+
// a fresh variable.
363+
ty::re_param(0u)
364+
}
360365
}
361366
}
362367
ast::re_named(_) | ast::re_self {
@@ -1488,7 +1493,8 @@ fn instantiate_self_regions(tcx: ty::ctxt, region: ty::region, &&ty: ty::t)
14881493
if ty::type_has_rptrs(ty) {
14891494
ty::fold_ty(tcx, ty::fm_rptr({|r|
14901495
alt r {
1491-
ty::re_inferred | ty::re_caller(_) | ty::re_self(_) { region }
1496+
// FIXME: Should not happen for re_param.
1497+
ty::re_param(_) | ty::re_caller(_) | ty::re_self(_) { region }
14921498
_ { r }
14931499
}
14941500
}), ty)
@@ -1502,7 +1508,10 @@ fn instantiate_self_regions(tcx: ty::ctxt, region: ty::region, &&ty: ty::t)
15021508
// refer to inferred regions.
15031509
fn universally_quantify_regions(tcx: ty::ctxt, ty: ty::t) -> ty::t {
15041510
if ty::type_has_rptrs(ty) {
1505-
ty::fold_ty(tcx, ty::fm_rptr({|_r| ty::re_inferred}), ty)
1511+
ty::fold_ty(tcx, ty::fm_rptr({|_r|
1512+
// FIXME: Very wrong. Shouldn't be 0u.
1513+
ty::re_param(0u)
1514+
}), ty)
15061515
} else {
15071516
ty
15081517
}

0 commit comments

Comments
 (0)