Skip to content

Commit 8774370

Browse files
committed
---
yaml --- r: 11814 b: refs/heads/master c: 0837a6b h: refs/heads/master v: v3
1 parent 6ca99d6 commit 8774370

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
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: 02e9400a82048b75c690308e2b9ca4a5cc1b155c
2+
refs/heads/master: 0837a6ba04bd3cf8330901678dc38b6f2c953f20
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustc/middle/ty.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ export param_bounds_to_kind;
135135
export default_arg_mode_for_ty;
136136
export item_path;
137137
export item_path_str;
138+
export ast_ty_to_ty_cache_entry;
139+
export atttce_unresolved, atttce_resolved, atttce_has_regions;
138140

139141
// Data types
140142

@@ -162,6 +164,12 @@ type creader_cache = hashmap<{cnum: int, pos: uint, len: uint}, t>;
162164

163165
type intern_key = {struct: sty, o_def_id: option<ast::def_id>};
164166

167+
enum ast_ty_to_ty_cache_entry {
168+
atttce_unresolved, /* not resolved yet */
169+
atttce_resolved(t), /* resolved to a type, irrespective of region */
170+
atttce_has_regions /* has regions; cannot be cached */
171+
}
172+
165173
type ctxt =
166174
@{interner: hashmap<intern_key, t_box>,
167175
mutable next_id: uint,
@@ -177,7 +185,7 @@ type ctxt =
177185
short_names_cache: hashmap<t, @str>,
178186
needs_drop_cache: hashmap<t, bool>,
179187
kind_cache: hashmap<t, kind>,
180-
ast_ty_to_ty_cache: hashmap<@ast::ty, option<t>>,
188+
ast_ty_to_ty_cache: hashmap<@ast::ty, ast_ty_to_ty_cache_entry>,
181189
enum_var_cache: hashmap<def_id, @[variant_info]>,
182190
iface_method_cache: hashmap<def_id, @[method]>,
183191
ty_param_bounds: hashmap<ast::node_id, param_bounds>,

trunk/src/rustc/middle/typeck.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,16 +270,16 @@ fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
270270
}
271271
}
272272
alt tcx.ast_ty_to_ty_cache.find(ast_ty) {
273-
some(some(ty)) { ret ty; }
274-
some(none) {
273+
some(ty::atttce_resolved(ty)) { ret ty; }
274+
some(ty::atttce_unresolved) {
275275
tcx.sess.span_fatal(ast_ty.span, "illegal recursive type. \
276276
insert a enum in the cycle, \
277277
if this is desired)");
278278
}
279-
none { }
280-
} /* go on */
279+
some(ty::atttce_has_regions) | none { /* go on */ }
280+
}
281281

282-
tcx.ast_ty_to_ty_cache.insert(ast_ty, none::<ty::t>);
282+
tcx.ast_ty_to_ty_cache.insert(ast_ty, ty::atttce_unresolved);
283283
fn ast_mt_to_mt(tcx: ty::ctxt, mode: mode, mt: ast::mt) -> ty::mt {
284284
ret {ty: ast_ty_to_ty(tcx, mode, mt.ty), mutbl: mt.mutbl};
285285
}
@@ -425,7 +425,13 @@ fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
425425
"found `ty_mac` in unexpected place");
426426
}
427427
};
428-
tcx.ast_ty_to_ty_cache.insert(ast_ty, some(typ));
428+
429+
if ty::type_has_rptrs(typ) {
430+
tcx.ast_ty_to_ty_cache.insert(ast_ty, ty::atttce_has_regions);
431+
} else {
432+
tcx.ast_ty_to_ty_cache.insert(ast_ty, ty::atttce_resolved(typ));
433+
}
434+
429435
ret typ;
430436
}
431437

0 commit comments

Comments
 (0)