Skip to content

Commit dbe1354

Browse files
committed
Move ast_map::map to LinearMap
1 parent b53057f commit dbe1354

25 files changed

+111
-113
lines changed

src/librustc/metadata/encoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ fn encode_info_for_items(ecx: @EncodeContext, ebml_w: writer::Encoder,
10261026
let ebml_w = copy ebml_w;
10271027
|i, cx, v| {
10281028
visit::visit_item(i, cx, v);
1029-
match ecx.tcx.items.get(&i.id) {
1029+
match *ecx.tcx.items.get(&i.id) {
10301030
ast_map::node_item(_, pt) => {
10311031
encode_info_for_item(ecx, ebml_w, i,
10321032
index, *pt);
@@ -1039,7 +1039,7 @@ fn encode_info_for_items(ecx: @EncodeContext, ebml_w: writer::Encoder,
10391039
let ebml_w = copy ebml_w;
10401040
|ni, cx, v| {
10411041
visit::visit_foreign_item(ni, cx, v);
1042-
match ecx.tcx.items.get(&ni.id) {
1042+
match *ecx.tcx.items.get(&ni.id) {
10431043
ast_map::node_foreign_item(_, abi, _, pt) => {
10441044
encode_info_for_foreign_item(ecx, ebml_w, ni,
10451045
index, /*bad*/copy *pt,

src/librustc/middle/check_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ pub fn check_item_recursion(sess: Session,
240240
match env.def_map.find(&e.id) {
241241
Some(&def_const(def_id)) => {
242242
if ast_util::is_local(def_id) {
243-
match env.ast_map.get(&def_id.node) {
243+
match *env.ast_map.get(&def_id.node) {
244244
ast_map::node_item(it, _) => {
245245
(v.visit_item)(it, env, v);
246246
}

src/librustc/middle/const_eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ pub fn lookup_const_by_id(tcx: ty::ctxt,
182182
if ast_util::is_local(def_id) {
183183
match tcx.items.find(&def_id.node) {
184184
None => None,
185-
Some(ast_map::node_item(it, _)) => match it.node {
185+
Some(&ast_map::node_item(it, _)) => match it.node {
186186
item_const(_, const_expr) => Some(const_expr),
187187
_ => None
188188
},

src/librustc/middle/privacy.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ pub fn check_crate(tcx: ty::ctxt,
113113
@fn(span: span, method_id: node_id) -> def_id =
114114
|span, method_id| {
115115
match tcx.items.find(&method_id) {
116-
Some(node_method(_, impl_id, _)) => impl_id,
117-
Some(node_trait_method(_, trait_id, _)) => trait_id,
116+
Some(&node_method(_, impl_id, _)) => impl_id,
117+
Some(&node_trait_method(_, trait_id, _)) => trait_id,
118118
Some(_) => {
119119
tcx.sess.span_bug(span,
120120
fmt!("method was a %s?!",
@@ -148,7 +148,7 @@ pub fn check_crate(tcx: ty::ctxt,
148148
}
149149
150150
match tcx.items.find(&container_id.node) {
151-
Some(node_item(item, _)) => {
151+
Some(&node_item(item, _)) => {
152152
match item.node {
153153
item_impl(_, None, _, _)
154154
if item.vis != public => {
@@ -170,10 +170,10 @@ pub fn check_crate(tcx: ty::ctxt,
170170
};
171171

172172
match tcx.items.find(&method_id) {
173-
Some(node_method(method, impl_id, _)) => {
173+
Some(&node_method(method, impl_id, _)) => {
174174
check(method.vis, impl_id)
175175
}
176-
Some(node_trait_method(trait_method, trait_id, _)) => {
176+
Some(&node_trait_method(trait_method, trait_id, _)) => {
177177
match *trait_method {
178178
required(_) => check(public, trait_id),
179179
provided(method) => check(method.vis, trait_id),
@@ -200,16 +200,16 @@ pub fn check_crate(tcx: ty::ctxt,
200200
let mut f: &fn(node_id) -> bool = |_| false;
201201
f = |item_id| {
202202
match tcx.items.find(&item_id) {
203-
Some(node_item(item, _)) => item.vis != public,
204-
Some(node_foreign_item(_, _, vis, _)) => vis != public,
205-
Some(node_method(method, impl_did, _)) => {
203+
Some(&node_item(item, _)) => item.vis != public,
204+
Some(&node_foreign_item(_, _, vis, _)) => vis != public,
205+
Some(&node_method(method, impl_did, _)) => {
206206
match method.vis {
207207
private => true,
208208
public => false,
209209
inherited => f(impl_did.node)
210210
}
211211
}
212-
Some(node_trait_method(_, trait_did, _)) => f(trait_did.node),
212+
Some(&node_trait_method(_, trait_did, _)) => f(trait_did.node),
213213
Some(_) => {
214214
tcx.sess.span_bug(span,
215215
fmt!("local_item_is_private: item was \
@@ -332,7 +332,7 @@ pub fn check_crate(tcx: ty::ctxt,
332332
method_super(trait_id, method_num) => {
333333
if trait_id.crate == local_crate {
334334
match tcx.items.find(&trait_id.node) {
335-
Some(node_item(item, _)) => {
335+
Some(&node_item(item, _)) => {
336336
match item.node {
337337
item_trait(_, _, ref methods) => {
338338
if method_num >= (*methods).len() {

src/librustc/middle/trans/base.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,7 +2065,7 @@ pub fn trans_enum_def(ccx: @CrateContext, enum_definition: ast::enum_def,
20652065
20662066
pub fn trans_item(ccx: @CrateContext, item: ast::item) {
20672067
let _icx = ccx.insn_ctxt("trans_item");
2068-
let path = match ccx.tcx.items.get(&item.id) {
2068+
let path = match *ccx.tcx.items.get(&item.id) {
20692069
ast_map::node_item(_, p) => p,
20702070
// tjc: ?
20712071
_ => fail!(~"trans_item"),
@@ -2336,13 +2336,12 @@ pub fn fill_fn_pair(bcx: block, pair: ValueRef, llfn: ValueRef,
23362336
}
23372337
23382338
pub fn item_path(ccx: @CrateContext, i: @ast::item) -> path {
2339-
vec::append(
2340-
/*bad*/copy *match ccx.tcx.items.get(&i.id) {
2341-
ast_map::node_item(_, p) => p,
2342-
// separate map for paths?
2343-
_ => fail!(~"item_path")
2344-
},
2345-
~[path_name(i.ident)])
2339+
let base = match *ccx.tcx.items.get(&i.id) {
2340+
ast_map::node_item(_, p) => p,
2341+
// separate map for paths?
2342+
_ => fail!(~"item_path")
2343+
};
2344+
vec::append(/*bad*/copy *base, ~[path_name(i.ident)])
23462345
}
23472346
23482347
/* If there's already a symbol for the dtor with <id> and substs <substs>,
@@ -2393,7 +2392,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef {
23932392
None => {
23942393
23952394
let mut exprt = false;
2396-
let val = match ccx.tcx.items.get(&id) {
2395+
let val = match *ccx.tcx.items.get(&id) {
23972396
ast_map::node_item(i, pth) => {
23982397
let my_path = vec::append(/*bad*/copy *pth,
23992398
~[path_name(i.ident)]);

src/librustc/middle/trans/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ pub fn trans_fn_ref_with_vtables(
268268
ccx.tcx.items.find(&def_id.node),
269269
|| fmt!("local item should be in ast map"));
270270

271-
match map_node {
271+
match *map_node {
272272
ast_map::node_foreign_item(_,
273273
ast::foreign_abi_rust_intrinsic,
274274
_,

src/librustc/middle/trans/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub fn get_const_val(cx: @CrateContext, def_id: ast::def_id) -> ValueRef {
158158
if !ast_util::is_local(def_id) {
159159
def_id = inline::maybe_instantiate_inline(cx, def_id, true);
160160
}
161-
match cx.tcx.items.get(&def_id.node) {
161+
match *cx.tcx.items.get(&def_id.node) {
162162
ast_map::node_item(@ast::item {
163163
node: ast::item_const(_, subexpr), _
164164
}, _) => {

src/librustc/middle/trans/debuginfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
849849
let sp = fcx.span.get();
850850
debug!("%s", cx.sess.codemap.span_to_str(sp));
851851

852-
let (ident, ret_ty, id) = match cx.tcx.items.get(&fcx.id) {
852+
let (ident, ret_ty, id) = match *cx.tcx.items.get(&fcx.id) {
853853
ast_map::node_item(item, _) => {
854854
match item.node {
855855
ast::item_fn(ref decl, _, _, _) => {

src/librustc/middle/trans/foreign.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
567567
let tp_sz = machine::llbitsize_of_real(ccx, lltp_ty),
568568
out_sz = machine::llbitsize_of_real(ccx, llout_ty);
569569
if tp_sz != out_sz {
570-
let sp = match ccx.tcx.items.get(&ref_id.get()) {
570+
let sp = match *ccx.tcx.items.get(&ref_id.get()) {
571571
ast_map::node_expr(e) => e.span,
572572
_ => fail!(~"reinterpret_cast or forget has non-expr arg")
573573
};
@@ -1082,7 +1082,7 @@ pub fn register_foreign_fn(ccx: @CrateContext,
10821082
fn abi_of_foreign_fn(ccx: @CrateContext, i: @ast::foreign_item)
10831083
-> ast::foreign_abi {
10841084
match attr::first_attr_value_str_by_name(i.attrs, ~"abi") {
1085-
None => match ccx.tcx.items.get(&i.id) {
1085+
None => match *ccx.tcx.items.get(&i.id) {
10861086
ast_map::node_foreign_item(_, abi, _, _) => abi,
10871087
// ??
10881088
_ => fail!(~"abi_of_foreign_fn: not foreign")

src/librustc/middle/trans/meth.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ pub fn trans_static_method_callee(bcx: block,
306306
};
307307
308308
let mname = if method_id.crate == ast::local_crate {
309-
match bcx.tcx().items.get(&method_id.node) {
309+
match *bcx.tcx().items.get(&method_id.node) {
310310
ast_map::node_trait_method(trait_method, _, _) => {
311311
ast_util::trait_method_to_ty_method(trait_method).ident
312312
}
@@ -361,7 +361,7 @@ pub fn method_from_methods(ms: &[@ast::method], name: ast::ident)
361361
pub fn method_with_name(ccx: @CrateContext, impl_id: ast::def_id,
362362
name: ast::ident) -> ast::def_id {
363363
if impl_id.crate == ast::local_crate {
364-
match ccx.tcx.items.get(&impl_id.node) {
364+
match *ccx.tcx.items.get(&impl_id.node) {
365365
ast_map::node_item(@ast::item {
366366
node: ast::item_impl(_, _, _, ref ms),
367367
_
@@ -378,7 +378,7 @@ pub fn method_with_name(ccx: @CrateContext, impl_id: ast::def_id,
378378
pub fn method_with_name_or_default(ccx: @CrateContext, impl_id: ast::def_id,
379379
name: ast::ident) -> ast::def_id {
380380
if impl_id.crate == ast::local_crate {
381-
match ccx.tcx.items.get(&impl_id.node) {
381+
match *ccx.tcx.items.get(&impl_id.node) {
382382
ast_map::node_item(@ast::item {
383383
node: ast::item_impl(_, _, _, ref ms), _
384384
}, _) => {
@@ -414,7 +414,7 @@ pub fn method_ty_param_count(ccx: @CrateContext, m_id: ast::def_id,
414414
debug!("method_ty_param_count: m_id: %?, i_id: %?", m_id, i_id);
415415
if m_id.crate == ast::local_crate {
416416
match ccx.tcx.items.find(&m_id.node) {
417-
Some(ast_map::node_method(m, _, _)) => m.generics.ty_params.len(),
417+
Some(&ast_map::node_method(m, _, _)) => m.generics.ty_params.len(),
418418
None => {
419419
match ccx.tcx.provided_method_sources.find(&m_id) {
420420
Some(source) => {
@@ -424,7 +424,7 @@ pub fn method_ty_param_count(ccx: @CrateContext, m_id: ast::def_id,
424424
None => fail!()
425425
}
426426
}
427-
Some(ast_map::node_trait_method(@ast::provided(@ref m),
427+
Some(&ast_map::node_trait_method(@ast::provided(@ref m),
428428
_, _)) => {
429429
m.generics.ty_params.len()
430430
}

0 commit comments

Comments
 (0)