Skip to content

Commit 1077677

Browse files
committed
rustc: Use only ast_ty_to_ty for region inference
1 parent 014dd54 commit 1077677

File tree

1 file changed

+4
-27
lines changed

1 file changed

+4
-27
lines changed

src/rustc/middle/region.rs

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ fn resolve_ty(ty: @ast::ty, cx: ctxt, visitor: visit::vt<ctxt>) {
104104

105105
alt ty.node {
106106
ast::ty_rptr({id: region_id, node: node}, _) {
107-
let region;
108107
alt node {
109-
ast::re_inferred { region = inferred_region; }
108+
ast::re_inferred | ast::re_self { /* no-op */ }
110109
ast::re_named(ident) {
111110
// If at item scope, introduce or reuse a binding. If at
112111
// block scope, require that the binding be introduced.
113112
let bindings = cx.bindings;
113+
let region;
114114
alt list::find(*bindings, {|b| ident == b.name}) {
115115
some(binding) { region = ty::re_named(binding.id); }
116116
none {
@@ -138,34 +138,11 @@ fn resolve_ty(ty: @ast::ty, cx: ctxt, visitor: visit::vt<ctxt>) {
138138
}
139139
}
140140
}
141-
}
142-
143-
ast::re_self {
144-
// For blocks, "self" means "the current block".
145-
//
146-
// TODO: What do we do in an alt?
147-
//
148-
// FIXME: Doesn't work in type items.
149141

150-
alt cx.parent {
151-
pa_item(item_id) | pa_nested_fn(item_id) {
152-
let def_id = {crate: ast::local_crate,
153-
node: item_id};
154-
region = ty::re_caller(def_id);
155-
}
156-
pa_block(block_id) {
157-
region = ty::re_block(block_id);
158-
}
159-
pa_crate {
160-
cx.sess.span_bug(ty.span,
161-
"region type outside item?!");
162-
}
163-
}
142+
let ast_type_to_region = cx.region_map.ast_type_to_region;
143+
ast_type_to_region.insert(region_id, region);
164144
}
165-
166145
}
167-
168-
cx.region_map.ast_type_to_region.insert(region_id, region);
169146
}
170147
_ { /* nothing to do */ }
171148
}

0 commit comments

Comments
 (0)