Skip to content

Commit f4a27b2

Browse files
committed
oldmap: get rid of the legacy contains_key method
1 parent 319eeb1 commit f4a27b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+86
-87
lines changed

src/libcargo/cargo.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,7 +1706,7 @@ pub fn cmd_sources(c: &Cargo) {
17061706
return;
17071707
}
17081708

1709-
if c.sources.contains_key(name) {
1709+
if c.sources.contains_key_ref(&name) {
17101710
error(fmt!("source already exists: %s", name));
17111711
} else {
17121712
c.sources.insert(name, @Source {
@@ -1733,7 +1733,7 @@ pub fn cmd_sources(c: &Cargo) {
17331733
return;
17341734
}
17351735

1736-
if c.sources.contains_key(name) {
1736+
if c.sources.contains_key_ref(&name) {
17371737
c.sources.remove(name);
17381738
info(fmt!("removed source: %s", name));
17391739
} else {

src/librustc/metadata/cstore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub fn set_crate_data(cstore: CStore,
9494
}
9595

9696
pub fn have_crate_data(cstore: CStore, cnum: ast::crate_num) -> bool {
97-
return p(cstore).metas.contains_key(cnum);
97+
return p(cstore).metas.contains_key_ref(&cnum);
9898
}
9999

100100
pub fn iter_crate_data(cstore: CStore,

src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub enum encode_ctxt = {
9999
};
100100

101101
pub fn reachable(ecx: @encode_ctxt, id: node_id) -> bool {
102-
ecx.reachable.contains_key(id)
102+
ecx.reachable.contains_key_ref(&id)
103103
}
104104

105105
fn encode_name(ecx: @encode_ctxt, ebml_w: writer::Encoder, name: ident) {

src/librustc/middle/borrowck/check_loans.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ fn check_loans_in_expr(expr: @ast::expr,
665665

666666
self.check_for_conflicting_loans(expr.id);
667667

668-
if self.bccx.moves_map.contains_key(expr.id) {
668+
if self.bccx.moves_map.contains_key_ref(&expr.id) {
669669
self.check_move_out_from_expr(expr);
670670
}
671671

@@ -686,15 +686,15 @@ fn check_loans_in_expr(expr: @ast::expr,
686686
}
687687
ast::expr_index(_, rval) |
688688
ast::expr_binary(_, _, rval)
689-
if self.bccx.method_map.contains_key(expr.id) => {
689+
if self.bccx.method_map.contains_key_ref(&expr.id) => {
690690
self.check_call(expr,
691691
None,
692692
expr.callee_id,
693693
expr.span,
694694
~[rval]);
695695
}
696696
ast::expr_unary(*) | ast::expr_index(*)
697-
if self.bccx.method_map.contains_key(expr.id) => {
697+
if self.bccx.method_map.contains_key_ref(&expr.id) => {
698698
self.check_call(expr,
699699
None,
700700
expr.callee_id,

src/librustc/middle/borrowck/gather_loans.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ fn req_loans_in_expr(ex: @ast::expr,
204204
ast::expr_binary(_, rcvr, _) |
205205
ast::expr_unary(_, rcvr) |
206206
ast::expr_assign_op(_, rcvr, _)
207-
if self.bccx.method_map.contains_key(ex.id) => {
207+
if self.bccx.method_map.contains_key_ref(&ex.id) => {
208208
// Receivers in method calls are always passed by ref.
209209
//
210210
// Here, in an overloaded operator, the call is this expression,
@@ -241,7 +241,7 @@ fn req_loans_in_expr(ex: @ast::expr,
241241
// }
242242

243243
ast::expr_field(rcvr, _, _)
244-
if self.bccx.method_map.contains_key(ex.id) => {
244+
if self.bccx.method_map.contains_key_ref(&ex.id) => {
245245
// Receivers in method calls are always passed by ref.
246246
//
247247
// Here, the field a.b is in fact a closure. Eventually, this

src/librustc/middle/borrowck/preserve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ impl PreserveCtxt {
375375
// scope_id;`. Though that would potentially re-introduce
376376
// the ICE. See #3511 for more details.
377377
let scope_to_use = if
378-
self.bccx.stmt_map.contains_key(scope_id) {
378+
self.bccx.stmt_map.contains_key_ref(&scope_id) {
379379
// Root it in its parent scope, b/c
380380
// trans won't introduce a new scope for the
381381
// stmt

src/librustc/middle/check_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub fn check_expr(sess: Session,
102102
}
103103
expr_lit(@codemap::spanned {node: lit_str(_), _}) => { }
104104
expr_binary(_, _, _) | expr_unary(_, _) => {
105-
if method_map.contains_key(e.id) {
105+
if method_map.contains_key_ref(&e.id) {
106106
sess.span_err(e.span, ~"user-defined operators are not \
107107
allowed in constant expressions");
108108
}

src/librustc/middle/check_match.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub fn expr_is_non_moving_lvalue(cx: @MatchCheckCtxt, expr: @expr) -> bool {
5959
return false;
6060
}
6161

62-
!cx.moves_map.contains_key(expr.id)
62+
!cx.moves_map.contains_key_ref(&expr.id)
6363
}
6464

6565
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,
734734
by_ref_span = Some(span);
735735
}
736736
bind_infer => {
737-
if cx.moves_map.contains_key(id) {
737+
if cx.moves_map.contains_key_ref(&id) {
738738
any_by_move = true;
739739
}
740740
}
@@ -774,7 +774,7 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt,
774774
if pat_is_binding(def_map, p) {
775775
match p.node {
776776
pat_ident(_, _, sub) => {
777-
if cx.moves_map.contains_key(p.id) {
777+
if cx.moves_map.contains_key_ref(&p.id) {
778778
check_move(p, sub);
779779
}
780780
}
@@ -800,7 +800,7 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt,
800800
behind_bad_pointer);
801801
802802
if behind_bad_pointer &&
803-
cx.moves_map.contains_key(pat.id)
803+
cx.moves_map.contains_key_ref(&pat.id)
804804
{
805805
cx.tcx.sess.span_err(
806806
pat.span,

src/librustc/middle/freevars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn collect_freevars(def_map: resolve::DefMap, blk: ast::blk)
7171
}
7272
if i == depth { // Made it to end of loop
7373
let dnum = ast_util::def_id_of_def(def).node;
74-
if !seen.contains_key(dnum) {
74+
if !seen.contains_key_ref(&dnum) {
7575
refs.push(@freevar_entry {
7676
def: def,
7777
span: expr.span,

src/librustc/middle/mem_categorization.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ pub impl &mem_categorization_ctxt {
348348
let expr_ty = tcx.ty(expr);
349349
match expr.node {
350350
ast::expr_unary(ast::deref, e_base) => {
351-
if self.method_map.contains_key(expr.id) {
351+
if self.method_map.contains_key_ref(&expr.id) {
352352
return self.cat_rvalue(expr, expr_ty);
353353
}
354354

@@ -357,7 +357,7 @@ pub impl &mem_categorization_ctxt {
357357
}
358358

359359
ast::expr_field(base, f_name, _) => {
360-
if self.method_map.contains_key(expr.id) {
360+
if self.method_map.contains_key_ref(&expr.id) {
361361
return self.cat_method_ref(expr, expr_ty);
362362
}
363363

@@ -366,7 +366,7 @@ pub impl &mem_categorization_ctxt {
366366
}
367367

368368
ast::expr_index(base, _) => {
369-
if self.method_map.contains_key(expr.id) {
369+
if self.method_map.contains_key_ref(&expr.id) {
370370
return self.cat_rvalue(expr, expr_ty);
371371
}
372372

src/librustc/middle/moves.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ impl VisitContext {
640640
arg_exprs: &[@expr],
641641
visitor: vt<VisitContext>) -> bool
642642
{
643-
if !self.method_map.contains_key(expr.id) {
643+
if !self.method_map.contains_key_ref(&expr.id) {
644644
return false;
645645
}
646646

@@ -771,7 +771,7 @@ impl VisitContext {
771771
for arm.pats.each |pat| {
772772
let mut found = false;
773773
do pat_bindings(self.tcx.def_map, *pat) |_, node_id, _, _| {
774-
if moves_map.contains_key(node_id) {
774+
if moves_map.contains_key_ref(&node_id) {
775775
found = true;
776776
}
777777
}

src/librustc/middle/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ pub fn resolve_expr(expr: @ast::expr, cx: ctxt, visitor: visit::vt<ctxt>) {
296296
_ => {}
297297
};
298298

299-
if new_cx.root_exprs.contains_key(expr.id) {
299+
if new_cx.root_exprs.contains_key_ref(&expr.id) {
300300
new_cx.parent = Some(expr.id);
301301
}
302302

src/librustc/middle/resolve.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,7 +2211,7 @@ pub impl Resolver {
22112211
}
22122212

22132213
// We've successfully resolved the import. Write the results in.
2214-
assert module_.import_resolutions.contains_key(target);
2214+
assert module_.import_resolutions.contains_key_ref(&target);
22152215
let import_resolution = module_.import_resolutions.get(target);
22162216

22172217
match value_result {
@@ -2370,7 +2370,7 @@ pub impl Resolver {
23702370
}
23712371

23722372
// We've successfully resolved the import. Write the results in.
2373-
assert module_.import_resolutions.contains_key(target);
2373+
assert module_.import_resolutions.contains_key_ref(&target);
23742374
let import_resolution = module_.import_resolutions.get(target);
23752375

23762376
match module_result {
@@ -4090,7 +4090,7 @@ pub impl Resolver {
40904090
}
40914091

40924092
for map_i.each |key, binding| {
4093-
if !map_0.contains_key(key) {
4093+
if !map_0.contains_key_ref(&key) {
40944094
self.session.span_err(
40954095
binding.span,
40964096
fmt!("variable `%s` from pattern #%u is \
@@ -4319,7 +4319,8 @@ pub impl Resolver {
43194319

43204320
match bindings_list {
43214321
Some(bindings_list)
4322-
if !bindings_list.contains_key(ident) => {
4322+
if !bindings_list.contains_key_ref(&ident)
4323+
=> {
43234324
let last_rib = (*self.value_ribs).last();
43244325
last_rib.bindings.insert(ident,
43254326
dl_def(def));
@@ -4391,16 +4392,19 @@ pub impl Resolver {
43914392
pat_struct(path, _, _) => {
43924393
match self.resolve_path(path, TypeNS, false, visitor) {
43934394
Some(def_ty(class_id))
4394-
if self.structs.contains_key(class_id) => {
4395+
if self.structs.contains_key_ref(&class_id)
4396+
=> {
43954397
let class_def = def_struct(class_id);
43964398
self.record_def(pattern.id, class_def);
43974399
}
43984400
Some(definition @ def_struct(class_id))
4399-
if self.structs.contains_key(class_id) => {
4401+
if self.structs.contains_key_ref(&class_id)
4402+
=> {
44004403
self.record_def(pattern.id, definition);
44014404
}
44024405
Some(definition @ def_variant(_, variant_id))
4403-
if self.structs.contains_key(variant_id) => {
4406+
if self.structs.contains_key_ref(&variant_id)
4407+
=> {
44044408
self.record_def(pattern.id, definition);
44054409
}
44064410
result => {
@@ -4848,12 +4852,12 @@ pub impl Resolver {
48484852

48494853
match self.resolve_path(path, TypeNS, false, visitor) {
48504854
Some(def_ty(class_id)) | Some(def_struct(class_id))
4851-
if self.structs.contains_key(class_id) => {
4855+
if self.structs.contains_key_ref(&class_id) => {
48524856
let class_def = def_struct(class_id);
48534857
self.record_def(expr.id, class_def);
48544858
}
48554859
Some(definition @ def_variant(_, class_id))
4856-
if self.structs.contains_key(class_id) => {
4860+
if self.structs.contains_key_ref(&class_id) => {
48574861
self.record_def(expr.id, definition);
48584862
}
48594863
_ => {
@@ -5073,7 +5077,7 @@ pub impl Resolver {
50735077
self.session.str_of(name));
50745078

50755079
match self.trait_info.find(trait_def_id) {
5076-
Some(trait_info) if trait_info.contains_key(name) => {
5080+
Some(trait_info) if trait_info.contains_key_ref(&name) => {
50775081
debug!("(adding trait info if containing method) found trait \
50785082
%d:%d for method '%s'",
50795083
trait_def_id.crate,

src/librustc/middle/trans/_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1586,7 +1586,7 @@ pub fn trans_match_inner(scope_cx: block,
15861586
// but during matching we need to store a *T as explained
15871587
// above
15881588
let is_move =
1589-
scope_cx.ccx().maps.moves_map.contains_key(p_id);
1589+
scope_cx.ccx().maps.moves_map.contains_key_ref(&p_id);
15901590
llmatch = alloca(bcx, T_ptr(llvariable_ty));
15911591
trmode = TrByValue(is_move, alloca(bcx, llvariable_ty));
15921592
}

src/librustc/middle/trans/base.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,7 @@ pub fn get_extern_fn(externs: HashMap<~str, ValueRef>,
169169
+name: ~str,
170170
cc: lib::llvm::CallConv,
171171
ty: TypeRef) -> ValueRef {
172-
// XXX: Bad copy.
173-
if externs.contains_key(copy name) { return externs.get(name); }
172+
if externs.contains_key_ref(&name) { return externs.get(name); }
174173
// XXX: Bad copy.
175174
let f = decl_fn(llmod, copy name, cc, ty);
176175
externs.insert(name, f);
@@ -180,8 +179,7 @@ pub fn get_extern_fn(externs: HashMap<~str, ValueRef>,
180179
pub fn get_extern_const(externs: HashMap<~str, ValueRef>, llmod: ModuleRef,
181180
+name: ~str, ty: TypeRef) -> ValueRef {
182181
unsafe {
183-
// XXX: Bad copy.
184-
if externs.contains_key(copy name) { return externs.get(name); }
182+
if externs.contains_key_ref(&name) { return externs.get(name); }
185183
let c = str::as_c_str(name, |buf| {
186184
llvm::LLVMAddGlobal(llmod, ty, buf)
187185
});
@@ -451,7 +449,7 @@ pub fn set_glue_inlining(f: ValueRef, t: ty::t) {
451449
// silently mangles such symbols, breaking our linkage model.
452450
pub fn note_unique_llvm_symbol(ccx: @crate_ctxt, +sym: ~str) {
453451
// XXX: Bad copy.
454-
if ccx.all_llvm_symbols.contains_key(copy sym) {
452+
if ccx.all_llvm_symbols.contains_key_ref(&sym) {
455453
ccx.sess.bug(~"duplicate LLVM symbol: " + sym);
456454
}
457455
ccx.all_llvm_symbols.insert(sym, ());
@@ -2485,7 +2483,7 @@ pub fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
24852483
ccx.sess.bug(~"get_item_val(): unexpected variant")
24862484
}
24872485
};
2488-
if !(exprt || ccx.reachable.contains_key(id)) {
2486+
if !(exprt || ccx.reachable.contains_key_ref(&id)) {
24892487
lib::llvm::SetLinkage(val, lib::llvm::InternalLinkage);
24902488
}
24912489
ccx.item_vals.insert(id, val);

src/librustc/middle/trans/callee.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,8 @@ pub fn trans_arg_expr(bcx: block,
672672
// FIXME(#3548) use the adjustments table
673673
match autoref_arg {
674674
DoAutorefArg => {
675-
assert !bcx.ccx().maps.moves_map.contains_key(arg_expr.id);
675+
assert !bcx.ccx().maps.moves_map.contains_key_ref(
676+
&arg_expr.id);
676677
val = arg_datum.to_ref_llval(bcx);
677678
}
678679
DontAutorefArg => {
@@ -682,16 +683,16 @@ pub fn trans_arg_expr(bcx: block,
682683
// the explicit self code currently passes by-ref, it
683684
// does not hold.
684685
//
685-
//assert !bcx.ccx().maps.moves_map.contains_key(
686-
// arg_expr.id);
686+
//assert !bcx.ccx().maps.moves_map.contains_key_ref(
687+
// &arg_expr.id);
687688
val = arg_datum.to_ref_llval(bcx);
688689
}
689690

690691
ast::by_val => {
691692
// NB: avoid running the take glue.
692693

693-
assert !bcx.ccx().maps.moves_map.contains_key(
694-
arg_expr.id);
694+
assert !bcx.ccx().maps.moves_map.contains_key_ref(
695+
&arg_expr.id);
695696
val = arg_datum.to_value_llval(bcx);
696697
}
697698

src/librustc/middle/trans/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub fn get_const_val(cx: @crate_ctxt, def_id: ast::def_id) -> ValueRef {
126126
if !ast_util::is_local(def_id) {
127127
cx.tcx.sess.bug(~"cross-crate constants");
128128
}
129-
if !cx.const_values.contains_key(def_id.node) {
129+
if !cx.const_values.contains_key_ref(&def_id.node) {
130130
match cx.tcx.items.get(def_id.node) {
131131
ast_map::node_item(@ast::item {
132132
node: ast::item_const(_, subexpr), _

src/librustc/middle/trans/controlflow.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ pub fn trans_log(log_ex: @ast::expr,
183183
// XXX: Bad copy.
184184
let modname = path_str(ccx.sess, copy modpath);
185185

186-
// XXX: Bad copy.
187-
let global = if ccx.module_data.contains_key(copy modname) {
186+
let global = if ccx.module_data.contains_key_ref(&modname) {
188187
ccx.module_data.get(modname)
189188
} else {
190189
let s = link::mangle_internal_name_by_path_and_seq(

src/librustc/middle/trans/datum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ pub impl Datum {
223223
* `id` is located in the move table, but copies otherwise.
224224
*/
225225

226-
if bcx.ccx().maps.moves_map.contains_key(id) {
226+
if bcx.ccx().maps.moves_map.contains_key_ref(&id) {
227227
self.move_to(bcx, action, dst)
228228
} else {
229229
self.copy_to(bcx, action, dst)

0 commit comments

Comments
 (0)