提交 f4a27b2c 编写于 作者: D Daniel Micay

oldmap: get rid of the legacy contains_key method

上级 319eeb1c
......@@ -1706,7 +1706,7 @@ pub fn cmd_sources(c: &Cargo) {
return;
}
if c.sources.contains_key(name) {
if c.sources.contains_key_ref(&name) {
error(fmt!("source already exists: %s", name));
} else {
c.sources.insert(name, @Source {
......@@ -1733,7 +1733,7 @@ pub fn cmd_sources(c: &Cargo) {
return;
}
if c.sources.contains_key(name) {
if c.sources.contains_key_ref(&name) {
c.sources.remove(name);
info(fmt!("removed source: %s", name));
} else {
......
......@@ -94,7 +94,7 @@ pub fn set_crate_data(cstore: CStore,
}
pub fn have_crate_data(cstore: CStore, cnum: ast::crate_num) -> bool {
return p(cstore).metas.contains_key(cnum);
return p(cstore).metas.contains_key_ref(&cnum);
}
pub fn iter_crate_data(cstore: CStore,
......
......@@ -99,7 +99,7 @@ pub enum encode_ctxt = {
};
pub fn reachable(ecx: @encode_ctxt, id: node_id) -> bool {
ecx.reachable.contains_key(id)
ecx.reachable.contains_key_ref(&id)
}
fn encode_name(ecx: @encode_ctxt, ebml_w: writer::Encoder, name: ident) {
......
......@@ -665,7 +665,7 @@ fn check_loans_in_expr(expr: @ast::expr,
self.check_for_conflicting_loans(expr.id);
if self.bccx.moves_map.contains_key(expr.id) {
if self.bccx.moves_map.contains_key_ref(&expr.id) {
self.check_move_out_from_expr(expr);
}
......@@ -686,7 +686,7 @@ fn check_loans_in_expr(expr: @ast::expr,
}
ast::expr_index(_, rval) |
ast::expr_binary(_, _, rval)
if self.bccx.method_map.contains_key(expr.id) => {
if self.bccx.method_map.contains_key_ref(&expr.id) => {
self.check_call(expr,
None,
expr.callee_id,
......@@ -694,7 +694,7 @@ fn check_loans_in_expr(expr: @ast::expr,
~[rval]);
}
ast::expr_unary(*) | ast::expr_index(*)
if self.bccx.method_map.contains_key(expr.id) => {
if self.bccx.method_map.contains_key_ref(&expr.id) => {
self.check_call(expr,
None,
expr.callee_id,
......
......@@ -204,7 +204,7 @@ fn req_loans_in_expr(ex: @ast::expr,
ast::expr_binary(_, rcvr, _) |
ast::expr_unary(_, rcvr) |
ast::expr_assign_op(_, rcvr, _)
if self.bccx.method_map.contains_key(ex.id) => {
if self.bccx.method_map.contains_key_ref(&ex.id) => {
// Receivers in method calls are always passed by ref.
//
// Here, in an overloaded operator, the call is this expression,
......@@ -241,7 +241,7 @@ fn req_loans_in_expr(ex: @ast::expr,
// }
ast::expr_field(rcvr, _, _)
if self.bccx.method_map.contains_key(ex.id) => {
if self.bccx.method_map.contains_key_ref(&ex.id) => {
// Receivers in method calls are always passed by ref.
//
// Here, the field a.b is in fact a closure. Eventually, this
......
......@@ -375,7 +375,7 @@ fn attempt_root(&self, cmt: cmt, base: cmt,
// scope_id;`. Though that would potentially re-introduce
// the ICE. See #3511 for more details.
let scope_to_use = if
self.bccx.stmt_map.contains_key(scope_id) {
self.bccx.stmt_map.contains_key_ref(&scope_id) {
// Root it in its parent scope, b/c
// trans won't introduce a new scope for the
// stmt
......
......@@ -102,7 +102,7 @@ pub fn check_expr(sess: Session,
}
expr_lit(@codemap::spanned {node: lit_str(_), _}) => { }
expr_binary(_, _, _) | expr_unary(_, _) => {
if method_map.contains_key(e.id) {
if method_map.contains_key_ref(&e.id) {
sess.span_err(e.span, ~"user-defined operators are not \
allowed in constant expressions");
}
......
......@@ -59,7 +59,7 @@ pub fn expr_is_non_moving_lvalue(cx: @MatchCheckCtxt, expr: @expr) -> bool {
return false;
}
!cx.moves_map.contains_key(expr.id)
!cx.moves_map.contains_key_ref(&expr.id)
}
pub fn check_expr(cx: @MatchCheckCtxt, ex: @expr, &&s: (), v: visit::vt<()>) {
......@@ -734,7 +734,7 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt,
by_ref_span = Some(span);
}
bind_infer => {
if cx.moves_map.contains_key(id) {
if cx.moves_map.contains_key_ref(&id) {
any_by_move = true;
}
}
......@@ -774,7 +774,7 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt,
if pat_is_binding(def_map, p) {
match p.node {
pat_ident(_, _, sub) => {
if cx.moves_map.contains_key(p.id) {
if cx.moves_map.contains_key_ref(&p.id) {
check_move(p, sub);
}
}
......@@ -800,7 +800,7 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt,
behind_bad_pointer);
if behind_bad_pointer &&
cx.moves_map.contains_key(pat.id)
cx.moves_map.contains_key_ref(&pat.id)
{
cx.tcx.sess.span_err(
pat.span,
......
......@@ -71,7 +71,7 @@ fn ignore_item(_i: @ast::item, &&_depth: int, _v: visit::vt<int>) { }
}
if i == depth { // Made it to end of loop
let dnum = ast_util::def_id_of_def(def).node;
if !seen.contains_key(dnum) {
if !seen.contains_key_ref(&dnum) {
refs.push(@freevar_entry {
def: def,
span: expr.span,
......
......@@ -348,7 +348,7 @@ fn cat_expr_unadjusted(expr: @ast::expr) -> cmt {
let expr_ty = tcx.ty(expr);
match expr.node {
ast::expr_unary(ast::deref, e_base) => {
if self.method_map.contains_key(expr.id) {
if self.method_map.contains_key_ref(&expr.id) {
return self.cat_rvalue(expr, expr_ty);
}
......@@ -357,7 +357,7 @@ fn cat_expr_unadjusted(expr: @ast::expr) -> cmt {
}
ast::expr_field(base, f_name, _) => {
if self.method_map.contains_key(expr.id) {
if self.method_map.contains_key_ref(&expr.id) {
return self.cat_method_ref(expr, expr_ty);
}
......@@ -366,7 +366,7 @@ fn cat_expr_unadjusted(expr: @ast::expr) -> cmt {
}
ast::expr_index(base, _) => {
if self.method_map.contains_key(expr.id) {
if self.method_map.contains_key_ref(&expr.id) {
return self.cat_rvalue(expr, expr_ty);
}
......
......@@ -640,7 +640,7 @@ fn use_overloaded_operator(&self,
arg_exprs: &[@expr],
visitor: vt<VisitContext>) -> bool
{
if !self.method_map.contains_key(expr.id) {
if !self.method_map.contains_key_ref(&expr.id) {
return false;
}
......@@ -771,7 +771,7 @@ fn arms_have_by_move_bindings(&self,
for arm.pats.each |pat| {
let mut found = false;
do pat_bindings(self.tcx.def_map, *pat) |_, node_id, _, _| {
if moves_map.contains_key(node_id) {
if moves_map.contains_key_ref(&node_id) {
found = true;
}
}
......
......@@ -296,7 +296,7 @@ pub fn resolve_expr(expr: @ast::expr, cx: ctxt, visitor: visit::vt<ctxt>) {
_ => {}
};
if new_cx.root_exprs.contains_key(expr.id) {
if new_cx.root_exprs.contains_key_ref(&expr.id) {
new_cx.parent = Some(expr.id);
}
......
......@@ -2211,7 +2211,7 @@ fn get_binding(import_resolution: @ImportResolution,
}
// We've successfully resolved the import. Write the results in.
assert module_.import_resolutions.contains_key(target);
assert module_.import_resolutions.contains_key_ref(&target);
let import_resolution = module_.import_resolutions.get(target);
match value_result {
......@@ -2370,7 +2370,7 @@ fn resolve_single_module_import(module_: @Module,
}
// We've successfully resolved the import. Write the results in.
assert module_.import_resolutions.contains_key(target);
assert module_.import_resolutions.contains_key_ref(&target);
let import_resolution = module_.import_resolutions.get(target);
match module_result {
......@@ -4090,7 +4090,7 @@ fn check_consistent_bindings(arm: arm) {
}
for map_i.each |key, binding| {
if !map_0.contains_key(key) {
if !map_0.contains_key_ref(&key) {
self.session.span_err(
binding.span,
fmt!("variable `%s` from pattern #%u is \
......@@ -4319,7 +4319,8 @@ struct in scope",
match bindings_list {
Some(bindings_list)
if !bindings_list.contains_key(ident) => {
if !bindings_list.contains_key_ref(&ident)
=> {
let last_rib = (*self.value_ribs).last();
last_rib.bindings.insert(ident,
dl_def(def));
......@@ -4391,16 +4392,19 @@ struct in scope",
pat_struct(path, _, _) => {
match self.resolve_path(path, TypeNS, false, visitor) {
Some(def_ty(class_id))
if self.structs.contains_key(class_id) => {
if self.structs.contains_key_ref(&class_id)
=> {
let class_def = def_struct(class_id);
self.record_def(pattern.id, class_def);
}
Some(definition @ def_struct(class_id))
if self.structs.contains_key(class_id) => {
if self.structs.contains_key_ref(&class_id)
=> {
self.record_def(pattern.id, definition);
}
Some(definition @ def_variant(_, variant_id))
if self.structs.contains_key(variant_id) => {
if self.structs.contains_key_ref(&variant_id)
=> {
self.record_def(pattern.id, definition);
}
result => {
......@@ -4848,12 +4852,12 @@ fn resolve_expr(expr: @expr, visitor: ResolveVisitor) {
match self.resolve_path(path, TypeNS, false, visitor) {
Some(def_ty(class_id)) | Some(def_struct(class_id))
if self.structs.contains_key(class_id) => {
if self.structs.contains_key_ref(&class_id) => {
let class_def = def_struct(class_id);
self.record_def(expr.id, class_def);
}
Some(definition @ def_variant(_, class_id))
if self.structs.contains_key(class_id) => {
if self.structs.contains_key_ref(&class_id) => {
self.record_def(expr.id, definition);
}
_ => {
......@@ -5073,7 +5077,7 @@ fn add_trait_info_if_containing_method(found_traits: @DVec<def_id>,
self.session.str_of(name));
match self.trait_info.find(trait_def_id) {
Some(trait_info) if trait_info.contains_key(name) => {
Some(trait_info) if trait_info.contains_key_ref(&name) => {
debug!("(adding trait info if containing method) found trait \
%d:%d for method '%s'",
trait_def_id.crate,
......
......@@ -1586,7 +1586,7 @@ pub fn trans_match_inner(scope_cx: block,
// but during matching we need to store a *T as explained
// above
let is_move =
scope_cx.ccx().maps.moves_map.contains_key(p_id);
scope_cx.ccx().maps.moves_map.contains_key_ref(&p_id);
llmatch = alloca(bcx, T_ptr(llvariable_ty));
trmode = TrByValue(is_move, alloca(bcx, llvariable_ty));
}
......
......@@ -169,8 +169,7 @@ pub fn get_extern_fn(externs: HashMap<~str, ValueRef>,
+name: ~str,
cc: lib::llvm::CallConv,
ty: TypeRef) -> ValueRef {
// XXX: Bad copy.
if externs.contains_key(copy name) { return externs.get(name); }
if externs.contains_key_ref(&name) { return externs.get(name); }
// XXX: Bad copy.
let f = decl_fn(llmod, copy name, cc, ty);
externs.insert(name, f);
......@@ -180,8 +179,7 @@ pub fn get_extern_fn(externs: HashMap<~str, ValueRef>,
pub fn get_extern_const(externs: HashMap<~str, ValueRef>, llmod: ModuleRef,
+name: ~str, ty: TypeRef) -> ValueRef {
unsafe {
// XXX: Bad copy.
if externs.contains_key(copy name) { return externs.get(name); }
if externs.contains_key_ref(&name) { return externs.get(name); }
let c = str::as_c_str(name, |buf| {
llvm::LLVMAddGlobal(llmod, ty, buf)
});
......@@ -451,7 +449,7 @@ pub fn set_glue_inlining(f: ValueRef, t: ty::t) {
// silently mangles such symbols, breaking our linkage model.
pub fn note_unique_llvm_symbol(ccx: @crate_ctxt, +sym: ~str) {
// XXX: Bad copy.
if ccx.all_llvm_symbols.contains_key(copy sym) {
if ccx.all_llvm_symbols.contains_key_ref(&sym) {
ccx.sess.bug(~"duplicate LLVM symbol: " + sym);
}
ccx.all_llvm_symbols.insert(sym, ());
......@@ -2485,7 +2483,7 @@ pub fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
ccx.sess.bug(~"get_item_val(): unexpected variant")
}
};
if !(exprt || ccx.reachable.contains_key(id)) {
if !(exprt || ccx.reachable.contains_key_ref(&id)) {
lib::llvm::SetLinkage(val, lib::llvm::InternalLinkage);
}
ccx.item_vals.insert(id, val);
......
......@@ -672,7 +672,8 @@ pub fn trans_arg_expr(bcx: block,
// FIXME(#3548) use the adjustments table
match autoref_arg {
DoAutorefArg => {
assert !bcx.ccx().maps.moves_map.contains_key(arg_expr.id);
assert !bcx.ccx().maps.moves_map.contains_key_ref(
&arg_expr.id);
val = arg_datum.to_ref_llval(bcx);
}
DontAutorefArg => {
......@@ -682,16 +683,16 @@ pub fn trans_arg_expr(bcx: block,
// the explicit self code currently passes by-ref, it
// does not hold.
//
//assert !bcx.ccx().maps.moves_map.contains_key(
// arg_expr.id);
//assert !bcx.ccx().maps.moves_map.contains_key_ref(
// &arg_expr.id);
val = arg_datum.to_ref_llval(bcx);
}
ast::by_val => {
// NB: avoid running the take glue.
assert !bcx.ccx().maps.moves_map.contains_key(
arg_expr.id);
assert !bcx.ccx().maps.moves_map.contains_key_ref(
&arg_expr.id);
val = arg_datum.to_value_llval(bcx);
}
......
......@@ -126,7 +126,7 @@ pub fn get_const_val(cx: @crate_ctxt, def_id: ast::def_id) -> ValueRef {
if !ast_util::is_local(def_id) {
cx.tcx.sess.bug(~"cross-crate constants");
}
if !cx.const_values.contains_key(def_id.node) {
if !cx.const_values.contains_key_ref(&def_id.node) {
match cx.tcx.items.get(def_id.node) {
ast_map::node_item(@ast::item {
node: ast::item_const(_, subexpr), _
......
......@@ -183,8 +183,7 @@ pub fn trans_log(log_ex: @ast::expr,
// XXX: Bad copy.
let modname = path_str(ccx.sess, copy modpath);
// XXX: Bad copy.
let global = if ccx.module_data.contains_key(copy modname) {
let global = if ccx.module_data.contains_key_ref(&modname) {
ccx.module_data.get(modname)
} else {
let s = link::mangle_internal_name_by_path_and_seq(
......
......@@ -223,7 +223,7 @@ fn store_to(bcx: block, id: ast::node_id,
* `id` is located in the move table, but copies otherwise.
*/
if bcx.ccx().maps.moves_map.contains_key(id) {
if bcx.ccx().maps.moves_map.contains_key_ref(&id) {
self.move_to(bcx, action, dst)
} else {
self.copy_to(bcx, action, dst)
......
......@@ -117,7 +117,7 @@ pub fn mk_ctxt(+crate: ~str, intr: @ident_interner) -> debug_ctxt {
}
fn update_cache(cache: metadata_cache, mdtag: int, val: debug_metadata) {
let existing = if cache.contains_key(mdtag) {
let existing = if cache.contains_key_ref(&mdtag) {
cache.get(mdtag)
} else {
~[]
......@@ -176,7 +176,7 @@ fn cached_metadata<T: Copy>(cache: metadata_cache,
eq_fn: fn(md: T) -> bool)
-> Option<T> {
unsafe {
if cache.contains_key(mdtag) {
if cache.contains_key_ref(&mdtag) {
let items = cache.get(mdtag);
for items.each |item| {
let md: T = md_from_metadata::<T>(*item);
......
......@@ -265,7 +265,7 @@ fn auto_slice_and_ref(bcx: block, datum: Datum) -> DatumBlock {
}
pub fn trans_into(bcx: block, expr: @ast::expr, dest: Dest) -> block {
if bcx.tcx().adjustments.contains_key(expr.id) {
if bcx.tcx().adjustments.contains_key_ref(&expr.id) {
// use trans_to_datum, which is mildly less efficient but
// which will perform the adjustments:
let datumblock = trans_to_datum(bcx, expr);
......@@ -426,7 +426,7 @@ fn trans_rvalue_datum_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
}
ast::expr_binary(op, lhs, rhs) => {
// if overloaded, would be RvalueDpsExpr
assert !bcx.ccx().maps.method_map.contains_key(expr.id);
assert !bcx.ccx().maps.method_map.contains_key_ref(&expr.id);
return trans_binary(bcx, expr, op, lhs, rhs);
}
......@@ -1243,7 +1243,7 @@ fn trans_unary_datum(bcx: block,
assert op != ast::deref;
// if overloaded, would be RvalueDpsExpr
assert !bcx.ccx().maps.method_map.contains_key(un_expr.id);
assert !bcx.ccx().maps.method_map.contains_key_ref(&un_expr.id);
let un_ty = expr_ty(bcx, un_expr);
let sub_ty = expr_ty(bcx, sub_expr);
......
......@@ -380,7 +380,7 @@ pub fn make_visit_glue(bcx: block, v: ValueRef, t: ty::t) {
let _icx = bcx.insn_ctxt("make_visit_glue");
let mut bcx = bcx;
let ty_visitor_name = special_idents::ty_visitor;
assert bcx.ccx().tcx.intrinsic_defs.contains_key(ty_visitor_name);
assert bcx.ccx().tcx.intrinsic_defs.contains_key_ref(&ty_visitor_name);
let (trait_id, ty) = bcx.ccx().tcx.intrinsic_defs.get(ty_visitor_name);
let v = PointerCast(bcx, v, T_ptr(type_of::type_of(bcx.ccx(), ty)));
bcx = reflect::emit_calls_to_trait_visit_ty(bcx, t, v, trait_id);
......
......@@ -178,7 +178,7 @@ pub fn llalign_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef {
// Computes the size of the data part of an enum.
pub fn static_size_of_enum(cx: @crate_ctxt, t: ty::t) -> uint {
if cx.enum_sizes.contains_key(t) { return cx.enum_sizes.get(t); }
if cx.enum_sizes.contains_key_ref(&t) { return cx.enum_sizes.get(t); }
match ty::get(t).sty {
ty::ty_enum(tid, ref substs) => {
// Compute max(variant sizes).
......
......@@ -871,7 +871,7 @@ pub fn trans_trait_cast(bcx: block,
match vstore {
ty::vstore_slice(*) | ty::vstore_box => {
let mut llboxdest = GEPi(bcx, lldest, [0u, 1u]);
if bcx.tcx().legacy_boxed_traits.contains_key(id) {
if bcx.tcx().legacy_boxed_traits.contains_key_ref(&id) {
// Allocate an @ box and store the value into it
let {bcx: new_bcx, box: llbox, body: body} =
malloc_boxed(bcx, v_ty);
......
......@@ -95,7 +95,7 @@ fn traverse_public_mod(cx: ctx, mod_id: node_id, m: _mod) {
}
fn traverse_public_item(cx: ctx, item: @item) {
if cx.rmap.contains_key(item.id) { return; }
if cx.rmap.contains_key_ref(&item.id) { return; }
cx.rmap.insert(item.id, ());
match /*bad*/copy item.node {
item_mod(m) => traverse_public_mod(cx, item.id, m),
......@@ -145,7 +145,7 @@ fn mk_ty_visitor() -> visit::vt<ctx> {
}
fn traverse_ty(ty: @Ty, cx: ctx, v: visit::vt<ctx>) {
if cx.rmap.contains_key(ty.id) { return; }
if cx.rmap.contains_key_ref(&ty.id) { return; }
cx.rmap.insert(ty.id, ());
match ty.node {
......
......@@ -316,7 +316,7 @@ pub fn emit_calls_to_trait_visit_ty(bcx: block,
-> block {
use syntax::parse::token::special_idents::tydesc;
let final = sub_block(bcx, ~"final");
assert bcx.ccx().tcx.intrinsic_defs.contains_key(tydesc);
assert bcx.ccx().tcx.intrinsic_defs.contains_key_ref(&tydesc);
let (_, tydesc_ty) = bcx.ccx().tcx.intrinsic_defs.get(tydesc);
let tydesc_ty = type_of::type_of(bcx.ccx(), tydesc_ty);
let r = reflector({
......
......@@ -87,7 +87,7 @@ pub fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
debug!("type_of %?: %?", t, ty::get(t));
// Check the cache.
if cx.lltypes.contains_key(t) { return cx.lltypes.get(t); }
if cx.lltypes.contains_key_ref(&t) { return cx.lltypes.get(t); }
// Replace any typedef'd types with their equivalent non-typedef
// type. This ensures that all LLVM nominal types that contain
......
......@@ -2817,7 +2817,7 @@ pub fn node_id_to_type_params(cx: ctxt, id: ast::node_id) -> ~[t] {
}
fn node_id_has_type_params(cx: ctxt, id: ast::node_id) -> bool {
return cx.node_type_substs.contains_key(id);
return cx.node_type_substs.contains_key_ref(&id);
}
// Type accessors for substructures of types
......@@ -3114,7 +3114,7 @@ pub enum ExprKind {
pub fn expr_kind(tcx: ctxt,
method_map: typeck::method_map,
expr: @ast::expr) -> ExprKind {
if method_map.contains_key(expr.id) {
if method_map.contains_key_ref(&expr.id) {
// Overloaded operations are generally calls, and hence they are
// generated via DPS. However, assign_op (e.g., `x += y`) is an
// exception, as its result is always unit.
......@@ -4368,7 +4368,7 @@ pub fn iter_bound_traits_and_supertraits(tcx: ctxt,
let super_t = supertrait.tpt.ty;
let d_id = ty_to_def_id(super_t).expect("supertrait \
should be a trait ty");
if !supertrait_map.contains_key(d_id) {
if !supertrait_map.contains_key_ref(&d_id) {
supertrait_map.insert(d_id, super_t);
trait_ty = super_t;
seen_def_ids.push(d_id);
......
......@@ -239,7 +239,7 @@ pub fn check_struct_pat_fields(pcx: pat_ctxt,
// Report an error if not all the fields were specified.
if !etc {
for class_fields.eachi |i, field| {
if found_fields.contains_key(i) {
if found_fields.contains_key_ref(&i) {
loop;
}
tcx.sess.span_err(span,
......
......@@ -1171,11 +1171,12 @@ fn enforce_drop_trait_limitations(&self, candidate: &Candidate) {
match candidate.origin {
method_static(method_id) | method_self(method_id, _)
| method_super(method_id, _) => {
bad = self.tcx().destructors.contains_key(method_id);
bad = self.tcx().destructors.contains_key_ref(&method_id);
}
method_param(method_param { trait_id: trait_id, _ }) |
method_trait(trait_id, _, _) => {
bad = self.tcx().destructor_for_type.contains_key(trait_id);
bad = self.tcx().destructor_for_type.contains_key_ref(
&trait_id);
}
}
......
......@@ -3078,8 +3078,8 @@ fn arg(m: ast::rmode, ty: ty::t) -> ty::arg {
~"visit_tydesc" => {
let tydesc_name = special_idents::tydesc;
let ty_visitor_name = tcx.sess.ident_of(~"TyVisitor");
assert tcx.intrinsic_defs.contains_key(tydesc_name);
assert ccx.tcx.intrinsic_defs.contains_key(ty_visitor_name);
assert tcx.intrinsic_defs.contains_key_ref(&tydesc_name);
assert ccx.tcx.intrinsic_defs.contains_key_ref(&ty_visitor_name);
let (_, tydesc_ty) = tcx.intrinsic_defs.get(tydesc_name);
let (_, visitor_trait) = tcx.intrinsic_defs.get(ty_visitor_name);
let td_ptr = ty::mk_ptr(ccx.tcx, ty::mt {ty: tydesc_ty,
......
......@@ -211,7 +211,7 @@ pub fn visit_expr(expr: @ast::expr, &&rcx: @rcx, v: rvt) {
// `constrain_auto_ref()` on all exprs. But that causes a
// lot of spurious errors because of how the region
// hierarchy is setup.
if rcx.fcx.ccx.method_map.contains_key(callee.id) {
if rcx.fcx.ccx.method_map.contains_key_ref(&callee.id) {
match callee.node {
ast::expr_field(base, _, _) => {
constrain_auto_ref(rcx, base);
......@@ -750,7 +750,7 @@ fn categorize_unadjusted(rcx: @rcx,
let _i = ::util::common::indenter();
let guarantor = {
if rcx.fcx.ccx.method_map.contains_key(expr.id) {
if rcx.fcx.ccx.method_map.contains_key_ref(&expr.id) {
None
} else {
guarantor(rcx, expr)
......
......@@ -268,7 +268,7 @@ pub fn lookup_vtable(vcx: &VtableContext,
// im is one specific impl of trait_ty.
// First, ensure we haven't processed this impl yet.
if impls_seen.contains_key(im.did) {
if impls_seen.contains_key_ref(&im.did) {
loop;
}
impls_seen.insert(im.did, ());
......
......@@ -141,7 +141,7 @@ fn maybe_resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span,
id: ast::node_id)
-> Option<ty::t>
{
if wbcx.fcx.inh.node_types.contains_key(id) {
if wbcx.fcx.inh.node_types.contains_key_ref(&id) {
resolve_type_vars_for_node(wbcx, sp, id)
} else {
None
......
......@@ -502,7 +502,7 @@ fn each_provided_trait_method(
}
for ty::trait_methods(tcx, trait_did).each |method| {
if provided_method_idents.contains_key(method.ident) {
if provided_method_idents.contains_key_ref(&method.ident) {
if !f(method) {
break;
}
......@@ -912,7 +912,7 @@ fn add_default_methods_for_external_trait(trait_def_id: ast::def_id) {
let tcx = self.crate_context.tcx;
let pmm = tcx.provided_methods;
if pmm.contains_key(trait_def_id) { return; }
if pmm.contains_key_ref(&trait_def_id) { return; }
debug!("(adding default methods for trait) processing trait");
......
......@@ -326,7 +326,7 @@ pub fn ensure_supertraits(ccx: @crate_ctxt,
rp: Option<ty::region_variance>,
trait_refs: &[@ast::trait_ref]) {
let tcx = ccx.tcx;
if tcx.supertraits.contains_key(local_def(id)) { return; }
if tcx.supertraits.contains_key_ref(&local_def(id)) { return; }
let instantiated = dvec::DVec();
for trait_refs.each |trait_ref| {
......
......@@ -164,10 +164,6 @@ fn rehash() {
impl<K:Eq IterBytes Hash Copy, V: Copy> T<K, V> {
pure fn size() -> uint { self.count }
pure fn contains_key(k: K) -> bool {
self.contains_key_ref(&k)
}
pure fn contains_key_ref(k: &K) -> bool {
let hash = k.hash_keyed(0,0) as uint;
match self.search_tbl(k, hash) {
......@@ -638,9 +634,9 @@ fn test_removal() {
fn test_contains_key() {
let key = ~"k";
let map = HashMap::<~str, ~str>();
assert (!map.contains_key(key));
assert (!map.contains_key_ref(&key));
map.insert(key, ~"val");
assert (map.contains_key(key));
assert (map.contains_key_ref(&key));
}
#[test]
......@@ -658,10 +654,10 @@ fn test_clear() {
let map = HashMap::<~str, ~str>();
map.insert(key, ~"val");
assert (map.size() == 1);
assert (map.contains_key(key));
assert (map.contains_key_ref(&key));
map.clear();
assert (map.size() == 0);
assert (!map.contains_key(key));
assert (!map.contains_key_ref(&key));
}
#[test]
......
......@@ -363,7 +363,7 @@ pub fn require_unique_names(diagnostic: span_handler,
let name = get_meta_item_name(*meta);
// FIXME: How do I silence the warnings? --pcw (#2619)
if map.contains_key(name) {
if map.contains_key_ref(&name) {
diagnostic.span_fatal(meta.span,
fmt!("duplicate meta item `%s`", name));
}
......
......@@ -197,7 +197,7 @@ fn n_rec(p_s: parse_sess, m: matcher, res: ~[@named_match],
codemap::spanned {
node: match_nonterminal(bind_name, _, idx), span: sp
} => {
if ret_val.contains_key(bind_name) {
if ret_val.contains_key_ref(&bind_name) {
p_s.span_diagnostic.span_fatal(sp, ~"Duplicated bind name: "+
*p_s.interner.get(bind_name))
}
......
......@@ -137,7 +137,7 @@ fn obsolete_expr(sp: span, kind: ObsoleteSyntax) -> @expr {
desc: &str) {
self.span_err(sp, fmt!("obsolete syntax: %s", kind_str));
if !self.obsolete_set.contains_key(kind) {
if !self.obsolete_set.contains_key_ref(&kind) {
self.sess.span_diagnostic.handler().note(fmt!("%s", desc));
self.obsolete_set.insert(kind, ());
}
......
......@@ -134,7 +134,7 @@ fn writer(path: ~str, pport: pipes::Port<Line>, size: uint)
done += 1_u;
let mut prev = done;
while prev <= i {
if lines.contains_key(prev) {
if lines.contains_key_ref(&prev) {
debug!("WS %u", prev);
cout.write(lines.get(prev));
done += 1_u;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册