Skip to content

Instantly share code, notes, and snippets.

@yjh0502
Created February 28, 2013 08:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yjh0502/5055072 to your computer and use it in GitHub Desktop.
Save yjh0502/5055072 to your computer and use it in GitHub Desktop.
diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs
index 86b07ab..0d3e1e6 100644
--- a/src/librustc/metadata/encoder.rs
+++ b/src/librustc/metadata/encoder.rs
@@ -937,7 +937,7 @@ fn encode_info_for_items(ecx: @EncodeContext, ebml_w: writer::Encoder,
|i, cx, v| {
visit::visit_item(i, cx, v);
match ecx.tcx.items.get(&i.id) {
- ast_map::node_item(_, pt) => {
+ &ast_map::node_item(_, pt) => {
encode_info_for_item(ecx, ebml_w, i,
index, *pt);
}
@@ -950,7 +950,7 @@ fn encode_info_for_items(ecx: @EncodeContext, ebml_w: writer::Encoder,
|ni, cx, v| {
visit::visit_foreign_item(ni, cx, v);
match ecx.tcx.items.get(&ni.id) {
- ast_map::node_foreign_item(_, abi, pt) => {
+ &ast_map::node_foreign_item(_, abi, pt) => {
encode_info_for_foreign_item(ecx, ebml_w, ni,
index, /*bad*/copy *pt,
abi);
diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs
index c86f7ea..6855183 100644
--- a/src/librustc/middle/check_const.rs
+++ b/src/librustc/middle/check_const.rs
@@ -249,7 +249,7 @@ pub fn check_item_recursion(sess: Session,
match env.def_map.find(&e.id) {
Some(def_const(def_id)) => {
match env.ast_map.get(&def_id.node) {
- ast_map::node_item(it, _) => {
+ &ast_map::node_item(it, _) => {
(v.visit_item)(it, env, v);
}
_ => fail!(~"const not bound to an item")
diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs
index ae83e99..9440928 100644
--- a/src/librustc/middle/const_eval.rs
+++ b/src/librustc/middle/const_eval.rs
@@ -182,7 +182,7 @@ pub fn lookup_const_by_id(tcx: ty::ctxt,
if ast_util::is_local(def_id) {
match tcx.items.find(&def_id.node) {
None => None,
- Some(ast_map::node_item(it, _)) => match it.node {
+ Some(&ast_map::node_item(it, _)) => match it.node {
item_const(_, const_expr) => Some(const_expr),
_ => None
},
diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs
index 3ec1cf3..78f6b76 100644
--- a/src/librustc/middle/privacy.rs
+++ b/src/librustc/middle/privacy.rs
@@ -106,7 +106,7 @@ pub fn check_crate(tcx: ty::ctxt,
method_static(method_id) => {
if method_id.crate == local_crate {
match tcx.items.find(&method_id.node) {
- Some(node_method(method, impl_id, _)) => {
+ Some(&node_method(method, impl_id, _)) => {
if method.vis == private &&
(impl_id.crate != local_crate ||
!privileged_items
@@ -144,7 +144,7 @@ pub fn check_crate(tcx: ty::ctxt,
method_super(trait_id, method_num) => {
if trait_id.crate == local_crate {
match tcx.items.find(&trait_id.node) {
- Some(node_item(item, _)) => {
+ Some(&node_item(item, _)) => {
match item.node {
item_trait(_, _, ref methods) => {
if method_num >= (*methods).len() {
diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs
index 9844aa5..ca8f8d1 100644
--- a/src/librustc/middle/trans/base.rs
+++ b/src/librustc/middle/trans/base.rs
@@ -2073,7 +2073,7 @@ pub fn trans_enum_def(ccx: @CrateContext, enum_definition: ast::enum_def,
pub fn trans_item(ccx: @CrateContext, item: ast::item) {
let _icx = ccx.insn_ctxt("trans_item");
let path = match ccx.tcx.items.get(&item.id) {
- ast_map::node_item(_, p) => p,
+ &ast_map::node_item(_, p) => p,
// tjc: ?
_ => fail!(~"trans_item"),
};
@@ -2330,7 +2330,7 @@ pub fn fill_fn_pair(bcx: block, pair: ValueRef, llfn: ValueRef,
pub fn item_path(ccx: @CrateContext, i: @ast::item) -> path {
vec::append(
/*bad*/copy *match ccx.tcx.items.get(&i.id) {
- ast_map::node_item(_, p) => p,
+ &ast_map::node_item(_, p) => p,
// separate map for paths?
_ => fail!(~"item_path")
},
@@ -2386,7 +2386,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef {
let mut exprt = false;
let val = match ccx.tcx.items.get(&id) {
- ast_map::node_item(i, pth) => {
+ &ast_map::node_item(i, pth) => {
let my_path = vec::append(/*bad*/copy *pth,
~[path_name(i.ident)]);
match i.node {
@@ -2422,7 +2422,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef {
_ => fail!(~"get_item_val: weird result in table")
}
}
- ast_map::node_trait_method(trait_method, _, pth) => {
+ &ast_map::node_trait_method(trait_method, _, pth) => {
debug!("get_item_val(): processing a node_trait_method");
match *trait_method {
ast::required(_) => {
@@ -2435,11 +2435,11 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef {
}
}
}
- ast_map::node_method(m, _, pth) => {
+ &ast_map::node_method(m, _, pth) => {
exprt = true;
register_method(ccx, id, pth, m)
}
- ast_map::node_foreign_item(ni, _, pth) => {
+ &ast_map::node_foreign_item(ni, _, pth) => {
exprt = true;
match ni.node {
ast::foreign_item_fn(*) => {
@@ -2463,7 +2463,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef {
}
}
}
- ast_map::node_dtor(_, dt, parent_id, pt) => {
+ &ast_map::node_dtor(_, dt, parent_id, pt) => {
/*
Don't just call register_fn, since we don't want to add
the implicit self argument automatically (we want to make sure
@@ -2488,7 +2488,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef {
llfn
}
- ast_map::node_variant(ref v, enm, pth) => {
+ &ast_map::node_variant(ref v, enm, pth) => {
let llfn;
match /*bad*/copy (*v).node.kind {
ast::tuple_variant_kind(args) => {
@@ -2514,7 +2514,8 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef {
llfn
}
- ast_map::node_struct_ctor(struct_def, struct_item, struct_path) => {
+ &ast_map::node_struct_ctor(struct_def, struct_item, struct_path)
+ => {
// Only register the constructor if this is a tuple-like struct.
match struct_def.ctor_id {
None => {
diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs
index 6924ccf..263f924 100644
--- a/src/librustc/middle/trans/callee.rs
+++ b/src/librustc/middle/trans/callee.rs
@@ -237,7 +237,7 @@ pub fn trans_fn_ref_with_vtables(
ccx.tcx.items.find(&def_id.node),
|| fmt!("local item should be in ast map"));
- match map_node {
+ match *map_node {
ast_map::node_foreign_item(_,
ast::foreign_abi_rust_intrinsic,
_) => {
diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs
index ab85da3..fbb5616 100644
--- a/src/librustc/middle/trans/consts.rs
+++ b/src/librustc/middle/trans/consts.rs
@@ -134,7 +134,7 @@ pub fn get_const_val(cx: @CrateContext, def_id: ast::def_id) -> ValueRef {
}
if !cx.const_values.contains_key(&def_id.node) {
match cx.tcx.items.get(&def_id.node) {
- ast_map::node_item(@ast::item {
+ &ast_map::node_item(@ast::item {
node: ast::item_const(_, subexpr), _
}, _) => {
trans_const(cx, subexpr, def_id.node);
diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs
index 8a28769..7c82a43 100644
--- a/src/librustc/middle/trans/debuginfo.rs
+++ b/src/librustc/middle/trans/debuginfo.rs
@@ -855,7 +855,7 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
log(debug, cx.sess.codemap.span_to_str(sp));
let (ident, ret_ty, id) = match cx.tcx.items.get(&fcx.id) {
- ast_map::node_item(item, _) => {
+ &ast_map::node_item(item, _) => {
match /*bad*/copy item.node {
ast::item_fn(decl, _, _, _) => {
(item.ident, decl.output, item.id)
@@ -864,10 +864,10 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
bound to non-function")
}
}
- ast_map::node_method(method, _, _) => {
+ &ast_map::node_method(method, _, _) => {
(method.ident, method.decl.output, method.id)
}
- ast_map::node_expr(expr) => {
+ &ast_map::node_expr(expr) => {
match /*bad*/copy expr.node {
ast::expr_fn(_, decl, _, _) => {
((dbg_cx.names)(~"fn"), decl.output, expr.id)
@@ -880,7 +880,7 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
expected an expr_fn or fn_block here")
}
}
- ast_map::node_dtor(_, _, did, _) => {
+ &ast_map::node_dtor(_, _, did, _) => {
((dbg_cx.names)(~"dtor"), ast_util::dtor_ty(), did.node)
}
_ => fcx.ccx.sess.bug(~"create_function: unexpected \
diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs
index ef9cc89..c7456fd 100644
--- a/src/librustc/middle/trans/foreign.rs
+++ b/src/librustc/middle/trans/foreign.rs
@@ -499,7 +499,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
out_sz = machine::llbitsize_of_real(ccx, llout_ty);
if tp_sz != out_sz {
let sp = match ccx.tcx.items.get(&ref_id.get()) {
- ast_map::node_expr(e) => e.span,
+ &ast_map::node_expr(e) => e.span,
_ => fail!(~"reinterpret_cast or forget has non-expr arg")
};
ccx.sess.span_fatal(
@@ -956,7 +956,7 @@ fn abi_of_foreign_fn(ccx: @CrateContext, i: @ast::foreign_item)
-> ast::foreign_abi {
match attr::first_attr_value_str_by_name(i.attrs, ~"abi") {
None => match ccx.tcx.items.get(&i.id) {
- ast_map::node_foreign_item(_, abi, _) => abi,
+ &ast_map::node_foreign_item(_, abi, _) => abi,
// ??
_ => fail!(~"abi_of_foreign_fn: not foreign")
},
diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs
index 02ea29f..08ed172 100644
--- a/src/librustc/middle/trans/meth.rs
+++ b/src/librustc/middle/trans/meth.rs
@@ -309,7 +309,7 @@ pub fn trans_static_method_callee(bcx: block,
let mname = if method_id.crate == ast::local_crate {
match bcx.tcx().items.get(&method_id.node) {
- ast_map::node_trait_method(trait_method, _, _) => {
+ &ast_map::node_trait_method(trait_method, _, _) => {
ast_util::trait_method_to_ty_method(*trait_method).ident
}
_ => fail!(~"callee is not a trait method")
@@ -363,7 +363,7 @@ pub fn method_with_name(ccx: @CrateContext, impl_id: ast::def_id,
name: ast::ident) -> ast::def_id {
if impl_id.crate == ast::local_crate {
match ccx.tcx.items.get(&impl_id.node) {
- ast_map::node_item(@ast::item {
+ &ast_map::node_item(@ast::item {
node: ast::item_impl(_, _, _, ref ms),
_
}, _) => {
@@ -380,7 +380,7 @@ pub fn method_with_name_or_default(ccx: @CrateContext, impl_id: ast::def_id,
name: ast::ident) -> ast::def_id {
if impl_id.crate == ast::local_crate {
match ccx.tcx.items.get(&impl_id.node) {
- ast_map::node_item(@ast::item {
+ &ast_map::node_item(@ast::item {
node: ast::item_impl(_, _, _, ref ms), _
}, _) => {
let did = method_from_methods(/*bad*/copy *ms, name);
@@ -415,7 +415,7 @@ pub fn method_ty_param_count(ccx: @CrateContext, m_id: ast::def_id,
debug!("method_ty_param_count: m_id: %?, i_id: %?", m_id, i_id);
if m_id.crate == ast::local_crate {
match ccx.tcx.items.find(&m_id.node) {
- Some(ast_map::node_method(m, _, _)) => m.tps.len(),
+ Some(&ast_map::node_method(m, _, _)) => m.tps.len(),
None => {
match ccx.tcx.provided_method_sources.find(&m_id) {
Some(source) => {
@@ -425,7 +425,7 @@ pub fn method_ty_param_count(ccx: @CrateContext, m_id: ast::def_id,
None => fail!()
}
}
- Some(ast_map::node_trait_method(@ast::provided(@ref m), _, _))
+ Some(&ast_map::node_trait_method(@ast::provided(@ref m), _, _))
=> {
m.tps.len()
}
diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs
index 9be316b..e72a550 100644
--- a/src/librustc/middle/trans/monomorphize.rs
+++ b/src/librustc/middle/trans/monomorphize.rs
@@ -86,7 +86,7 @@ pub fn monomorphic_fn(ccx: @CrateContext,
(may have attempted to monomorphize an item defined in a different \
crate?)", fn_id));
// Get the path so that we can create a symbol
- let (pt, name, span) = match map_node {
+ let (pt, name, span) = match *map_node {
ast_map::node_item(i, pt) => (pt, i.ident, i.span),
ast_map::node_variant(ref v, enm, pt) => (pt, (*v).node.name, enm.span),
ast_map::node_method(m, _, pt) => (pt, m.ident, m.span),
@@ -162,7 +162,7 @@ pub fn monomorphic_fn(ccx: @CrateContext,
self_ty: impl_ty_opt
});
- let lldecl = match map_node {
+ let lldecl = match *map_node {
ast_map::node_item(i@@ast::item {
// XXX: Bad copy.
node: ast::item_fn(ref decl, _, _, ref body),
diff --git a/src/librustc/middle/trans/reachable.rs b/src/librustc/middle/trans/reachable.rs
index d56d28c..95d0a0e 100644
--- a/src/librustc/middle/trans/reachable.rs
+++ b/src/librustc/middle/trans/reachable.rs
@@ -72,7 +72,7 @@ fn traverse_def_id(cx: ctx, did: def_id) {
None => return, // This can happen for self, for example
Some(ref n) => (/*bad*/copy *n)
};
- match n {
+ match *n {
ast_map::node_item(item, _) => traverse_public_item(cx, item),
ast_map::node_method(_, impl_id, _) => traverse_def_id(cx, impl_id),
ast_map::node_foreign_item(item, _, _) => {
diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs
index 2fc7497..3f0b21c 100644
--- a/src/librustc/middle/trans/type_use.rs
+++ b/src/librustc/middle/trans/type_use.rs
@@ -99,7 +99,7 @@ pub fn type_uses_for(ccx: @CrateContext, fn_id: def_id, n_tps: uint)
None => ccx.sess.bug(fmt!("type_uses_for: unbound item ID %?",
fn_id_loc))
};
- match map_node {
+ match *map_node {
ast_map::node_item(@ast::item { node: item_fn(_, _, _, ref body),
_ }, _) |
ast_map::node_method(@ast::method {body: ref body, _}, _, _) => {
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs
index 182ab11..8e64c27 100644
--- a/src/librustc/middle/ty.rs
+++ b/src/librustc/middle/ty.rs
@@ -3542,7 +3542,7 @@ pub fn store_trait_methods(cx: ctxt, id: ast::node_id, ms: @~[method]) {
pub fn provided_trait_methods(cx: ctxt, id: ast::def_id) -> ~[ast::ident] {
if is_local(id) {
match cx.items.find(&id.node) {
- Some(ast_map::node_item(@ast::item {
+ Some(&ast_map::node_item(@ast::item {
node: item_trait(_, _, ref ms),
_
}, _)) =>
@@ -3628,7 +3628,7 @@ pub fn impl_traits(cx: ctxt, id: ast::def_id, vstore: vstore) -> ~[t] {
if id.crate == ast::local_crate {
debug!("(impl_traits) searching for trait impl %?", id);
match cx.items.find(&id.node) {
- Some(ast_map::node_item(@ast::item {
+ Some(&ast_map::node_item(@ast::item {
node: ast::item_impl(_, opt_trait, _, _),
_},
_)) => {
@@ -3664,7 +3664,7 @@ fn struct_ctor_id(cx: ctxt, struct_did: ast::def_id) -> Option<ast::def_id> {
}
match cx.items.find(&struct_did.node) {
- Some(ast_map::node_item(item, _)) => {
+ Some(&ast_map::node_item(item, _)) => {
match item.node {
ast::item_struct(struct_def, _) => {
struct_def.ctor_id.map(|ctor_id|
@@ -3736,7 +3736,7 @@ pub fn ty_dtor(cx: ctxt, struct_id: def_id) -> DtorKind {
if is_local(struct_id) {
match cx.items.find(&struct_id.node) {
- Some(ast_map::node_item(@ast::item {
+ Some(&ast_map::node_item(@ast::item {
node: ast::item_struct(@ast::struct_def { dtor: Some(ref dtor),
_ },
_),
@@ -3764,7 +3764,7 @@ pub fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
csearch::get_item_path(cx, id)
} else {
let node = cx.items.get(&id.node);
- match node {
+ match *node {
ast_map::node_item(item, path) => {
let item_elt = match item.node {
item_mod(_) | item_foreign_mod(_) => {
@@ -3841,7 +3841,7 @@ pub fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[VariantInfo] {
expr, since check_enum_variants also updates the enum_var_cache
*/
match cx.items.get(&id.node) {
- ast_map::node_item(@ast::item {
+ &ast_map::node_item(@ast::item {
node: ast::item_enum(ref enum_definition, _),
_
}, _) => {
@@ -3957,7 +3957,7 @@ pub fn lookup_field_type(tcx: ctxt,
pub fn lookup_struct_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] {
if did.crate == ast::local_crate {
match cx.items.find(&did.node) {
- Some(ast_map::node_item(i,_)) => {
+ Some(&ast_map::node_item(i,_)) => {
match i.node {
ast::item_struct(struct_def, _) => {
struct_field_tys(/*bad*/copy struct_def.fields)
@@ -3965,7 +3965,7 @@ pub fn lookup_struct_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] {
_ => cx.sess.bug(~"struct ID bound to non-struct")
}
}
- Some(ast_map::node_variant(ref variant, _, _)) => {
+ Some(&ast_map::node_variant(ref variant, _, _)) => {
match (*variant).node.kind {
ast::struct_variant_kind(struct_def) => {
struct_field_tys(/*bad*/copy struct_def.fields)
diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs
index 34b650a..ef449b5 100644
--- a/src/librustc/middle/typeck/check/method.rs
+++ b/src/librustc/middle/typeck/check/method.rs
@@ -1232,7 +1232,7 @@ pub impl LookupContext {
fn report_static_candidate(&self, idx: uint, did: def_id) {
let span = if did.crate == ast::local_crate {
match self.tcx().items.find(&did.node) {
- Some(ast_map::node_method(m, _, _)) => m.span,
+ Some(&ast_map::node_method(m, _, _)) => m.span,
_ => fail!(fmt!("report_static_candidate: bad item %?", did))
}
} else {
diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs
index e63e46a..cb2f42c 100644
--- a/src/librustc/middle/typeck/check/mod.rs
+++ b/src/librustc/middle/typeck/check/mod.rs
@@ -1058,14 +1058,14 @@ pub fn impl_self_ty(vcx: &VtableContext,
let (n_tps, region_param, raw_ty) = if did.crate == ast::local_crate {
let region_param = tcx.region_paramd_items.find(&did.node);
match tcx.items.find(&did.node) {
- Some(ast_map::node_item(@ast::item {
+ Some(&ast_map::node_item(@ast::item {
node: ast::item_impl(ref ts, _, st, _),
_
}, _)) => {
(ts.len(), region_param,
vcx.ccx.to_ty(rscope::type_rscope(region_param), st))
}
- Some(ast_map::node_item(@ast::item {
+ Some(&ast_map::node_item(@ast::item {
node: ast::item_struct(_, ref ts),
id: class_id,
_
@@ -1861,7 +1861,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
region_parameterized =
tcx.region_paramd_items.find(&class_id.node);
match tcx.items.find(&class_id.node) {
- Some(ast_map::node_item(@ast::item {
+ Some(&ast_map::node_item(@ast::item {
node: ast::item_struct(_, ref type_parameters),
_
}, _)) => {
@@ -1945,7 +1945,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
region_parameterized =
tcx.region_paramd_items.find(&enum_id.node);
match tcx.items.find(&enum_id.node) {
- Some(ast_map::node_item(@ast::item {
+ Some(&ast_map::node_item(@ast::item {
node: ast::item_enum(_, ref type_parameters),
_
}, _)) => {
diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs
index 29738f2..1192274 100644
--- a/src/librustc/middle/typeck/coherence.rs
+++ b/src/librustc/middle/typeck/coherence.rs
@@ -817,7 +817,7 @@ pub impl CoherenceChecker {
fn span_of_impl(&self, implementation: @Impl) -> span {
assert implementation.did.crate == local_crate;
match self.crate_context.tcx.items.find(&implementation.did.node) {
- Some(node_item(item, _)) => {
+ Some(&node_item(item, _)) => {
return item.span;
}
_ => {
@@ -1022,7 +1022,7 @@ pub impl CoherenceChecker {
// Destructors only work on nominal types.
if impl_info.did.crate == ast::local_crate {
match tcx.items.find(&impl_info.did.node) {
- Some(ast_map::node_item(@ref item, _)) => {
+ Some(&ast_map::node_item(@ref item, _)) => {
tcx.sess.span_err((*item).span,
~"the Drop trait may only \
be implemented on \
diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs
index 96c76b5..e5f1d05 100644
--- a/src/librustc/middle/typeck/collect.rs
+++ b/src/librustc/middle/typeck/collect.rs
@@ -130,10 +130,10 @@ pub impl AstConv for CrateCtxt {
csearch::get_type(self.tcx, id)
} else {
match self.tcx.items.find(&id.node) {
- Some(ast_map::node_item(item, _)) => {
+ Some(&ast_map::node_item(item, _)) => {
ty_of_item(self, item)
}
- Some(ast_map::node_foreign_item(foreign_item, _, _)) => {
+ Some(&ast_map::node_foreign_item(foreign_item, _, _)) => {
ty_of_foreign_item(self, foreign_item)
}
ref x => {
@@ -275,10 +275,9 @@ pub fn ensure_trait_methods(ccx: @mut CrateCtxt,
let tcx = ccx.tcx;
let region_paramd = tcx.region_paramd_items.find(&id);
match tcx.items.get(&id) {
- ast_map::node_item(@ast::item {
- node: ast::item_trait(ref params, _, ref ms),
- _
- }, _) => {
+ &ast_map::node_item(@ast::item {
+ node: ast::item_trait(ref params, _, ref ms), _}
+ , _) => {
store_methods::<ast::trait_method>(ccx, id, (/*bad*/copy *ms), |m| {
let def_id;
match *m {
@@ -505,7 +504,7 @@ pub fn check_methods_against_trait(ccx: @mut CrateCtxt,
// the methods within the trait with bogus results. (See issue #3903.)
match tcx.items.find(&did.node) {
- Some(ast_map::node_item(item, _)) => {
+ Some(&ast_map::node_item(item, _)) => {
let tpt = ty_of_item(ccx, item);
ensure_trait_methods(ccx, did.node, tpt.ty);
}
diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs
index de3df62..1a11cf8 100644
--- a/src/librustc/middle/typeck/mod.rs
+++ b/src/librustc/middle/typeck/mod.rs
@@ -324,7 +324,7 @@ fn check_main_fn_ty(ccx: @mut CrateCtxt,
match ty::get(main_t).sty {
ty::ty_bare_fn(ref fn_ty) => {
match tcx.items.find(&main_id) {
- Some(ast_map::node_item(it,_)) => {
+ Some(&ast_map::node_item(it,_)) => {
match it.node {
ast::item_fn(_, _, ref ps, _)
if !ps.is_empty() => {
diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs
index a337431..93311fe 100644
--- a/src/librustc/util/ppaux.rs
+++ b/src/librustc/util/ppaux.rs
@@ -69,10 +69,10 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region)
return match region {
re_scope(node_id) => {
match cx.items.find(&node_id) {
- Some(ast_map::node_block(ref blk)) => {
+ Some(&ast_map::node_block(ref blk)) => {
explain_span(cx, "block", (*blk).span)
}
- Some(ast_map::node_expr(expr)) => {
+ Some(&ast_map::node_expr(expr)) => {
match expr.node {
ast::expr_call(*) => explain_span(cx, "call", expr.span),
ast::expr_method_call(*) => {
@@ -82,10 +82,10 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region)
_ => explain_span(cx, "expression", expr.span)
}
}
- Some(ast_map::node_stmt(stmt)) => {
+ Some(&ast_map::node_stmt(stmt)) => {
explain_span(cx, "statement", stmt.span)
}
- Some(ast_map::node_item(it, _)) if (match it.node {
+ Some(&ast_map::node_item(it, _)) if (match it.node {
ast::item_fn(*) => true, _ => false}) => {
explain_span(cx, "function body", it.span)
}
@@ -107,7 +107,7 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region)
};
match cx.items.find(&id) {
- Some(ast_map::node_block(ref blk)) => {
+ Some(&ast_map::node_block(ref blk)) => {
let (msg, opt_span) = explain_span(cx, "block", (*blk).span);
(fmt!("%s %s", prefix, msg), opt_span)
}
@@ -157,11 +157,11 @@ pub fn bound_region_to_str_adorned(cx: ctxt, prefix: &str,
pub fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> ~str {
match cx.items.find(&node_id) {
- Some(ast_map::node_block(ref blk)) => {
+ Some(&ast_map::node_block(ref blk)) => {
fmt!("<block at %s>",
cx.sess.codemap.span_to_str((*blk).span))
}
- Some(ast_map::node_expr(expr)) => {
+ Some(&ast_map::node_expr(expr)) => {
match expr.node {
ast::expr_call(*) => {
fmt!("<call at %s>",
diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs
index 74f6780..9e97c1b 100644
--- a/src/libsyntax/ast_map.rs
+++ b/src/libsyntax/ast_map.rs
@@ -25,8 +25,7 @@ use core::cmp;
use core::either;
use core::str;
use core::vec;
-use std::oldmap::HashMap;
-use std::oldmap;
+use core::hashmap::linear::LinearMap;
use std;
pub enum path_elt {
@@ -106,7 +105,7 @@ pub enum ast_node {
node_struct_ctor(@struct_def, @item, @path),
}
-pub type map = std::oldmap::HashMap<node_id, ast_node>;
+pub type map = @mut LinearMap<node_id, ast_node>;
pub struct Ctx {
map: @map,
@@ -136,7 +135,7 @@ pub fn mk_ast_map_visitor() -> vt {
pub fn map_crate(diag: span_handler, c: crate) -> map {
let cx = @mut Ctx {
- map: @std::oldmap::HashMap(),
+ map: @@mut LinearMap::new(),
path: ~[],
local_id: 0u,
diag: diag,
@@ -172,7 +171,7 @@ pub fn map_decoded_item(diag: span_handler,
match ii {
ii_item(*) | ii_dtor(*) => { /* fallthrough */ }
ii_foreign(i) => {
- cx.map.insert(i.id, node_foreign_item(i, foreign_abi_rust_intrinsic,
+ cx.map.insert(i.id, node_foreign_item(i, foreign_abi_rust_intrinsic,
@path));
}
ii_method(impl_did, m) => {
@@ -341,7 +340,7 @@ pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str {
None => {
fmt!("unknown node (id=%d)", id)
}
- Some(node_item(item, path)) => {
+ Some(&node_item(item, path)) => {
let path_str = path_ident_to_str(*path, item.ident, itr);
let item_str = match item.node {
item_const(*) => ~"const",
@@ -357,43 +356,43 @@ pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str {
};
fmt!("%s %s (id=%?)", item_str, path_str, id)
}
- Some(node_foreign_item(item, abi, path)) => {
+ Some(&node_foreign_item(item, abi, path)) => {
fmt!("foreign item %s with abi %? (id=%?)",
path_ident_to_str(*path, item.ident, itr), abi, id)
}
- Some(node_method(m, _, path)) => {
+ Some(&node_method(m, _, path)) => {
fmt!("method %s in %s (id=%?)",
*itr.get(m.ident), path_to_str(*path, itr), id)
}
- Some(node_trait_method(tm, _, path)) => {
+ Some(&node_trait_method(tm, _, path)) => {
let m = ast_util::trait_method_to_ty_method(*tm);
fmt!("method %s in %s (id=%?)",
*itr.get(m.ident), path_to_str(*path, itr), id)
}
- Some(node_variant(ref variant, _, path)) => {
+ Some(&node_variant(ref variant, _, path)) => {
fmt!("variant %s in %s (id=%?)",
*itr.get((*variant).node.name), path_to_str(*path, itr), id)
}
- Some(node_expr(expr)) => {
+ Some(&node_expr(expr)) => {
fmt!("expr %s (id=%?)", pprust::expr_to_str(expr, itr), id)
}
- Some(node_stmt(stmt)) => {
+ Some(&node_stmt(stmt)) => {
fmt!("stmt %s (id=%?)",
pprust::stmt_to_str(*stmt, itr), id)
}
- Some(node_arg(_, _)) => { // add more info here
+ Some(&node_arg(_, _)) => { // add more info here
fmt!("arg (id=%?)", id)
}
- Some(node_local(_)) => { // add more info here
+ Some(&node_local(_)) => { // add more info here
fmt!("local (id=%?)", id)
}
- Some(node_dtor(*)) => { // add more info here
+ Some(&node_dtor(*)) => { // add more info here
fmt!("node_dtor (id=%?)", id)
}
- Some(node_block(_)) => {
+ Some(&node_block(_)) => {
fmt!("block")
}
- Some(node_struct_ctor(*)) => {
+ Some(&node_struct_ctor(*)) => {
fmt!("struct_ctor")
}
}
@@ -403,7 +402,7 @@ pub fn node_item_query<Result>(items: map, id: node_id,
query: fn(@item) -> Result,
error_msg: ~str) -> Result {
match items.find(&id) {
- Some(node_item(it, _)) => query(it),
+ Some(&node_item(it, _)) => query(it),
_ => fail!(error_msg)
}
}
diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs
index b345b11..b7e5a4d 100644
--- a/src/libsyntax/ext/auto_encode.rs
+++ b/src/libsyntax/ext/auto_encode.rs
@@ -98,8 +98,7 @@ use ext::base::*;
use parse;
use core::vec;
-use std::oldmap;
-use std::oldmap::HashMap;
+use core::hashmap::linear::LinearMap;
// Transitional reexports so qquote can find the paths it is looking for
mod syntax {
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index f3a7430..547f2df 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -21,7 +21,7 @@ use parse::{parser, token};
use core::io;
use core::vec;
-use std::oldmap::HashMap;
+use core::hashmap::linear::LinearMap;
// new-style macro! tt code:
//
@@ -76,7 +76,7 @@ pub enum SyntaxExtension {
ItemTT(SyntaxExpanderTTItem),
}
-type SyntaxExtensions = HashMap<@~str, SyntaxExtension>;
+type SyntaxExtensions = @mut LinearMap<@~str, SyntaxExtension>;
// A temporary hard-coded map of methods for expanding syntax extension
// AST nodes into full ASTs
@@ -89,7 +89,7 @@ pub fn syntax_expander_table() -> SyntaxExtensions {
fn builtin_item_tt(f: SyntaxExpanderTTItemFun) -> SyntaxExtension {
ItemTT(SyntaxExpanderTTItem{expander: f, span: None})
}
- let syntax_expanders = HashMap();
+ let syntax_expanders = @mut LinearMap::new();
syntax_expanders.insert(@~"macro_rules",
builtin_item_tt(
ext::tt::macro_rules::add_new_extension));
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 0b2aaa8..85f621b 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -21,7 +21,7 @@ use parse::{parser, parse_expr_from_source_str, new_parser_from_tts};
use core::option;
use core::vec;
-use std::oldmap::HashMap;
+use core::hashmap::linear::LinearMap;
pub fn expand_expr(exts: SyntaxExtensions, cx: ext_ctxt,
e: expr_, s: span, fld: ast_fold,
@@ -46,7 +46,7 @@ pub fn expand_expr(exts: SyntaxExtensions, cx: ext_ctxt,
cx.span_fatal(pth.span,
fmt!("macro undefined: '%s'", *extname))
}
- Some(NormalTT(SyntaxExpanderTT{expander: exp,
+ Some(&NormalTT(SyntaxExpanderTT{expander: exp,
span: exp_sp})) => {
cx.bt_push(ExpandedFrom(CallInfo{
call_site: s,
@@ -107,8 +107,8 @@ pub fn expand_mod_items(exts: SyntaxExtensions, cx: ext_ctxt,
let mname = attr::get_attr_name(attr);
match exts.find(&mname) {
- None | Some(NormalTT(_)) | Some(ItemTT(*)) => items,
- Some(ItemDecorator(dec_fn)) => {
+ None | Some(&NormalTT(_)) | Some(&ItemTT(*)) => items,
+ Some(&ItemDecorator(dec_fn)) => {
cx.bt_push(ExpandedFrom(CallInfo {
call_site: attr.span,
callee: NameAndSpan {
@@ -171,7 +171,7 @@ pub fn expand_item_mac(exts: SyntaxExtensions,
None => cx.span_fatal(pth.span,
fmt!("macro undefined: '%s!'", *extname)),
- Some(NormalTT(ref expand)) => {
+ Some(&NormalTT(ref expand)) => {
if it.ident != parse::token::special_idents::invalid {
cx.span_fatal(pth.span,
fmt!("macro %s! expects no ident argument, \
@@ -187,7 +187,7 @@ pub fn expand_item_mac(exts: SyntaxExtensions,
}));
((*expand).expander)(cx, it.span, tts)
}
- Some(ItemTT(ref expand)) => {
+ Some(&ItemTT(ref expand)) => {
if it.ident == parse::token::special_idents::invalid {
cx.span_fatal(pth.span,
fmt!("macro %s! expects an ident argument",
@@ -242,7 +242,7 @@ pub fn expand_stmt(exts: SyntaxExtensions, cx: ext_ctxt,
None =>
cx.span_fatal(pth.span, fmt!("macro undefined: '%s'", *extname)),
- Some(NormalTT(
+ Some(&NormalTT(
SyntaxExpanderTT{expander: exp, span: exp_sp})) => {
cx.bt_push(ExpandedFrom(CallInfo {
call_site: sp,
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index 890420e..ff9a1c4 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.rs
@@ -26,7 +26,7 @@ use core::option;
use core::str;
use core::uint;
use core::vec;
-use std::oldmap::HashMap;
+use core::hashmap::linear::LinearMap;
/* This is an Earley-like parser, without support for in-grammar nonterminals,
only by calling out to the main rust parser for named nonterminals (which it
@@ -191,9 +191,9 @@ pub enum named_match {
pub type earley_item = ~MatcherPos;
pub fn nameize(p_s: @mut ParseSess, ms: ~[matcher], res: ~[@named_match])
- -> HashMap<ident,@named_match> {
+ -> @mut LinearMap<ident,@named_match> {
fn n_rec(p_s: @mut ParseSess, m: matcher, res: ~[@named_match],
- ret_val: HashMap<ident, @named_match>) {
+ ret_val: @mut LinearMap<ident, @named_match>) {
match m {
codemap::spanned {node: match_tok(_), _} => (),
codemap::spanned {node: match_seq(ref more_ms, _, _, _, _), _} => {
@@ -212,19 +212,19 @@ pub fn nameize(p_s: @mut ParseSess, ms: ~[matcher], res: ~[@named_match])
}
}
}
- let ret_val = HashMap();
+ let ret_val = @mut LinearMap::new();
for ms.each() |m| { n_rec(p_s, *m, res, ret_val) }
return ret_val;
}
pub enum parse_result {
- success(HashMap<ident, @named_match>),
+ success(@mut LinearMap<ident, @named_match>),
failure(codemap::span, ~str),
error(codemap::span, ~str)
}
pub fn parse_or_else(sess: @mut ParseSess, cfg: ast::crate_cfg, rdr: reader,
- ms: ~[matcher]) -> HashMap<ident, @named_match> {
+ ms: ~[matcher]) -> @mut LinearMap<ident, @named_match> {
match parse(sess, cfg, rdr, ms) {
success(m) => m,
failure(sp, ref str) => sess.span_diagnostic.span_fatal(sp, (*str)),
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index f42bb01..72bdeef 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -26,7 +26,7 @@ use parse::token::{FAT_ARROW, SEMI, LBRACE, RBRACE, nt_matchers, nt_tt};
use print;
use core::io;
-use std::oldmap::HashMap;
+use core::hashmap::linear::LinearMap;
pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
arg: ~[ast::token_tree]) -> base::MacResult {
@@ -60,13 +60,13 @@ pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
// Extract the arguments:
let lhses = match argument_map.get(&lhs_nm) {
- @matched_seq(ref s, _) => /* FIXME (#2543) */ copy *s,
+ &@matched_seq(ref s, _) => /* FIXME (#2543) */ copy *s,
_ => cx.span_bug(sp, ~"wrong-structured lhs")
};
let rhses = match argument_map.get(&rhs_nm) {
- @matched_seq(ref s, _) => /* FIXME (#2543) */ copy *s,
- _ => cx.span_bug(sp, ~"wrong-structured rhs")
+ &@matched_seq(ref s, _) => /* FIXME (#2543) */ copy *s,
+ _ => cx.span_bug(sp, ~"wrong-structured rhs")
};
// Given `lhses` and `rhses`, this is the new macro we create
diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs
index a9502ff..4d5e530 100644
--- a/src/libsyntax/ext/tt/transcribe.rs
+++ b/src/libsyntax/ext/tt/transcribe.rs
@@ -21,8 +21,7 @@ use parse::lexer::TokenAndSpan;
use core::option;
use core::vec;
-use std;
-use std::oldmap::HashMap;
+use core::hashmap::linear::LinearMap;
/* FIXME #2811: figure out how to have a uniquely linked stack, and change to
`~` */
@@ -40,7 +39,7 @@ pub struct TtReader {
interner: @ident_interner,
cur: @mut TtFrame,
/* for MBE-style macro transcription */
- interpolations: std::oldmap::HashMap<ident, @named_match>,
+ interpolations: @mut LinearMap<ident, @named_match>,
repeat_idx: ~[uint],
repeat_len: ~[uint],
/* cached: */
@@ -53,7 +52,7 @@ pub struct TtReader {
* should) be none. */
pub fn new_tt_reader(sp_diag: span_handler,
itr: @ident_interner,
- interp: Option<std::oldmap::HashMap<ident,@named_match>>,
+ interp: Option<@mut LinearMap<ident,@named_match>>,
src: ~[ast::token_tree])
-> @mut TtReader {
let r = @mut TtReader {
@@ -67,7 +66,7 @@ pub fn new_tt_reader(sp_diag: span_handler,
up: option::None
},
interpolations: match interp { /* just a convienience */
- None => std::oldmap::HashMap(),
+ None => @mut LinearMap::new(),
Some(x) => x
},
repeat_idx: ~[],
@@ -122,7 +121,7 @@ pure fn lookup_cur_matched_by_matched(r: @mut TtReader,
}
fn lookup_cur_matched(r: @mut TtReader, name: ident) -> @named_match {
- lookup_cur_matched_by_matched(r, r.interpolations.get(&name))
+ lookup_cur_matched_by_matched(r, *r.interpolations.get(&name))
}
enum lis {
lis_unconstrained, lis_constraint(uint, ident), lis_contradiction(~str)
diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs
index 57d62d6..bbe6d9c 100644
--- a/src/libsyntax/parse/common.rs
+++ b/src/libsyntax/parse/common.rs
@@ -18,7 +18,6 @@ use parse::token;
use core::option::{None, Option, Some};
use core::option;
-use std::oldmap::HashMap;
// SeqSep : a sequence separator (token)
// and whether a trailing separator is allowed.
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index e9eab96..bc11b23 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -90,7 +90,7 @@ use core::either;
use core::result::Result;
use core::vec::push;
use core::vec;
-use std::oldmap::HashMap;
+use core::hashmap::linear::LinearMap;
#[deriving_eq]
enum restriction {
@@ -214,7 +214,7 @@ pub fn Parser(sess: @mut ParseSess,
keywords: token::keyword_table(),
strict_keywords: token::strict_keyword_table(),
reserved_keywords: token::reserved_keyword_table(),
- obsolete_set: HashMap(),
+ obsolete_set: @mut LinearMap::new(),
mod_path_stack: @mut ~[],
}
}
@@ -233,12 +233,12 @@ pub struct Parser {
quote_depth: @mut uint, // not (yet) related to the quasiquoter
reader: reader,
interner: @token::ident_interner,
- keywords: HashMap<~str, ()>,
- strict_keywords: HashMap<~str, ()>,
- reserved_keywords: HashMap<~str, ()>,
+ keywords: @mut LinearMap<~str, ()>,
+ strict_keywords: @mut LinearMap<~str, ()>,
+ reserved_keywords: @mut LinearMap<~str, ()>,
/// The set of seen errors about obsolete syntax. Used to suppress
/// extra detail when the same error is seen twice
- obsolete_set: HashMap<ObsoleteSyntax, ()>,
+ obsolete_set: @mut LinearMap<ObsoleteSyntax, ()>,
/// Used to determine the path to externally loaded source files
mod_path_stack: @mut ~[~str],
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index f145e43..3ea731e 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -21,7 +21,7 @@ use core::char;
use core::cmp;
use core::str;
use core::task;
-use std::oldmap::HashMap;
+use core::hashmap::linear::LinearMap;
#[auto_encode]
#[auto_decode]
@@ -455,8 +455,8 @@ pub fn mk_fake_ident_interner() -> @ident_interner {
* appear as identifiers at all. Reserved keywords are not used anywhere in
* the language and may not appear as identifiers.
*/
-pub fn keyword_table() -> HashMap<~str, ()> {
- let keywords = HashMap();
+pub fn keyword_table() -> @mut LinearMap<~str, ()> {
+ let keywords = @mut LinearMap::new();
for temporary_keyword_table().each_key |&word| {
keywords.insert(word, ());
}
@@ -470,8 +470,8 @@ pub fn keyword_table() -> HashMap<~str, ()> {
}
/// Keywords that may be used as identifiers
-pub fn temporary_keyword_table() -> HashMap<~str, ()> {
- let words = HashMap();
+pub fn temporary_keyword_table() -> @mut LinearMap<~str, ()> {
+ let mut words = @mut LinearMap::new();
let keys = ~[
~"self", ~"static",
];
@@ -482,8 +482,8 @@ pub fn temporary_keyword_table() -> HashMap<~str, ()> {
}
/// Full keywords. May not appear anywhere else.
-pub fn strict_keyword_table() -> HashMap<~str, ()> {
- let words = HashMap();
+pub fn strict_keyword_table() -> @mut LinearMap<~str, ()> {
+ let words = @mut LinearMap::new();
let keys = ~[
~"as", ~"assert",
~"break",
@@ -508,8 +508,8 @@ pub fn strict_keyword_table() -> HashMap<~str, ()> {
words
}
-pub fn reserved_keyword_table() -> HashMap<~str, ()> {
- let words = HashMap();
+pub fn reserved_keyword_table() -> @mut LinearMap<~str, ()> {
+ let words = @mut LinearMap::new();
let keys = ~[
~"be"
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment