Skip to content

auto: oldmap: use &K instead of K in find and get #4777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/libcargo/cargo.rc
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ pub fn configure(opts: Options) -> Cargo {
need_dir(&c.bindir);

for sources.each_key_ref |&k| {
let mut s = sources.get(k);
let mut s = sources.get(&k);
load_source_packages(&c, s);
sources.insert(k, s);
}
Expand Down Expand Up @@ -981,7 +981,7 @@ pub fn install_named(c: &mut Cargo, wd: &Path, name: ~str) {

pub fn install_uuid_specific(c: &mut Cargo, wd: &Path, src: ~str,
uuid: ~str) {
match c.sources.find(src) {
match c.sources.find(&src) {
Some(s) => {
for s.packages.each |p| {
if p.uuid == uuid {
Expand All @@ -997,7 +997,7 @@ pub fn install_uuid_specific(c: &mut Cargo, wd: &Path, src: ~str,

pub fn install_named_specific(c: &mut Cargo, wd: &Path, src: ~str,
name: ~str) {
match c.sources.find(src) {
match c.sources.find(&src) {
Some(s) => {
for s.packages.each |p| {
if p.name == name {
Expand Down Expand Up @@ -1064,7 +1064,7 @@ pub fn cmd_uninstall(c: &Cargo) {
}

pub fn install_query(c: &mut Cargo, wd: &Path, target: ~str) {
match c.dep_cache.find(target) {
match c.dep_cache.find(&target) {
Some(inst) => {
if inst {
return;
Expand Down Expand Up @@ -1156,7 +1156,7 @@ pub fn cmd_install(c: &mut Cargo) {

pub fn sync(c: &Cargo) {
for c.sources.each_key_ref |&k| {
let mut s = c.sources.get(k);
let mut s = c.sources.get(&k);
sync_one(c, s);
c.sources.insert(k, s);
}
Expand Down Expand Up @@ -1558,7 +1558,7 @@ pub fn cmd_list(c: &Cargo) {
if !valid_pkg_name(*name) {
error(fmt!("'%s' is an invalid source name", *name));
} else {
match c.sources.find(*name) {
match c.sources.find(name) {
Some(source) => {
print_source(source);
}
Expand Down Expand Up @@ -1754,7 +1754,7 @@ pub fn cmd_sources(c: &Cargo) {
return;
}

match c.sources.find(name) {
match c.sources.find(&name) {
Some(source) => {
let old = copy source.url;
let method = assume_source_method(url);
Expand Down Expand Up @@ -1785,7 +1785,7 @@ pub fn cmd_sources(c: &Cargo) {
return;
}

match c.sources.find(name) {
match c.sources.find(&name) {
Some(source) => {
let old = copy source.method;

Expand Down Expand Up @@ -1823,7 +1823,7 @@ pub fn cmd_sources(c: &Cargo) {
return;
}

match c.sources.find(name) {
match c.sources.find(&name) {
Some(source) => {
c.sources.remove(&name);
c.sources.insert(newn, source);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ pub fn symbol_hash(tcx: ty::ctxt, symbol_hasher: &hash::State, t: ty::t,
}
pub fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> @str {
match ccx.type_hashcodes.find(t) {
match ccx.type_hashcodes.find(&t) {
Some(h) => h,
None => {
let hash = symbol_hash(ccx.tcx, ccx.symbol_hasher, t, ccx.link_meta);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ pub fn build_session_options(+binary: ~str,
getopts::opt_strs(matches, level_name));
for flags.each |lint_name| {
let lint_name = str::replace(*lint_name, ~"-", ~"_");
match lint_dict.find(/*bad*/ copy lint_name) {
match lint_dict.find(&lint_name) {
None => {
early_error(demitter, fmt!("unknown %s flag: %s",
level_name, lint_name));
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/lib/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1331,11 +1331,11 @@ pub fn associate_type(tn: type_names, s: @str, t: TypeRef) {
}

pub fn type_has_name(tn: type_names, t: TypeRef) -> Option<@str> {
return tn.type_names.find(t);
return tn.type_names.find(&t);
}

pub fn name_has_type(tn: type_names, s: @str) -> Option<TypeRef> {
return tn.named_types.find(s);
return tn.named_types.find(&s);
}

pub fn mk_type_names() -> type_names {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn mk_cstore(intr: @ident_interner) -> CStore {

pub fn get_crate_data(cstore: CStore, cnum: ast::crate_num)
-> crate_metadata {
return p(cstore).metas.get(cnum);
return p(cstore).metas.get(&cnum);
}

pub fn get_crate_hash(cstore: CStore, cnum: ast::crate_num) -> ~str {
Expand Down Expand Up @@ -139,7 +139,7 @@ pub fn add_use_stmt_cnum(cstore: CStore, use_id: ast::node_id,

pub fn find_use_stmt_cnum(cstore: CStore,
use_id: ast::node_id) -> Option<ast::crate_num> {
p(cstore).use_crate_map.find(use_id)
p(cstore).use_crate_map.find(&use_id)
}

// returns hashes of crates directly used by this crate. Hashes are
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ pub fn translate_def_id(cdata: cmd, did: ast::def_id) -> ast::def_id {
return ast::def_id { crate: cdata.cnum, node: did.node };
}

match cdata.cnum_map.find(did.crate) {
match cdata.cnum_map.find(&did.crate) {
option::Some(n) => ast::def_id { crate: n, node: did.node },
option::None => die!(~"didn't find a crate in the cnum_map")
}
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub fn encode_def_id(ebml_w: writer::Encoder, id: def_id) {

fn encode_region_param(ecx: @encode_ctxt, ebml_w: writer::Encoder,
it: @ast::item) {
let opt_rp = ecx.tcx.region_paramd_items.find(it.id);
let opt_rp = ecx.tcx.region_paramd_items.find(&it.id);
for opt_rp.each |rp| {
do ebml_w.wr_tag(tag_region_param) {
(*rp).encode(&ebml_w);
Expand Down Expand Up @@ -184,7 +184,7 @@ fn encode_ty_type_param_bounds(ebml_w: writer::Encoder, ecx: @encode_ctxt,
fn encode_type_param_bounds(ebml_w: writer::Encoder, ecx: @encode_ctxt,
params: &[ty_param]) {
let ty_param_bounds =
@params.map(|param| ecx.tcx.ty_param_bounds.get(param.id));
@params.map(|param| ecx.tcx.ty_param_bounds.get(&param.id));
encode_ty_type_param_bounds(ebml_w, ecx, ty_param_bounds);
}

Expand Down Expand Up @@ -224,7 +224,7 @@ fn encode_type(ecx: @encode_ctxt, ebml_w: writer::Encoder, typ: ty::t) {

fn encode_symbol(ecx: @encode_ctxt, ebml_w: writer::Encoder, id: node_id) {
ebml_w.start_tag(tag_items_data_item_symbol);
let sym = match ecx.item_symbols.find(id) {
let sym = match ecx.item_symbols.find(&id) {
Some(ref x) => (/*bad*/copy *x),
None => {
ecx.diag.handler().bug(
Expand All @@ -238,7 +238,7 @@ fn encode_symbol(ecx: @encode_ctxt, ebml_w: writer::Encoder, id: node_id) {
fn encode_discriminant(ecx: @encode_ctxt, ebml_w: writer::Encoder,
id: node_id) {
ebml_w.start_tag(tag_items_data_item_symbol);
ebml_w.writer.write(str::to_bytes(ecx.discrim_symbols.get(id)));
ebml_w.writer.write(str::to_bytes(ecx.discrim_symbols.get(&id)));
ebml_w.end_tag();
}

Expand Down Expand Up @@ -349,7 +349,7 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: writer::Encoder,

// Encode the reexports of this module.
debug!("(encoding info for module) encoding reexports for %d", id);
match ecx.reexports2.find(id) {
match ecx.reexports2.find(&id) {
Some(ref exports) => {
debug!("(encoding info for module) found reexports for %d", id);
for (*exports).each |exp| {
Expand Down Expand Up @@ -813,7 +813,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: writer::Encoder,
encode_name(ecx, ebml_w, ty_m.ident);
encode_family(ebml_w,
purity_static_method_family(ty_m.purity));
let polyty = ecx.tcx.tcache.get(local_def(ty_m.id));
let polyty = ecx.tcx.tcache.get(&local_def(ty_m.id));
encode_ty_type_param_bounds(ebml_w, ecx, polyty.bounds);
encode_type(ecx, ebml_w, polyty.ty);
let mut m_path = vec::append(~[], path); // :-(
Expand Down Expand Up @@ -881,7 +881,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: writer::Encoder,
let ebml_w = copy ebml_w;
|i, cx, v| {
visit::visit_item(i, cx, v);
match ecx.tcx.items.get(i.id) {
match ecx.tcx.items.get(&i.id) {
ast_map::node_item(_, pt) => {
encode_info_for_item(ecx, ebml_w, i,
index, *pt);
Expand All @@ -894,7 +894,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: writer::Encoder,
let ebml_w = copy ebml_w;
|ni, cx, v| {
visit::visit_foreign_item(ni, cx, v);
match ecx.tcx.items.get(ni.id) {
match ecx.tcx.items.get(&ni.id) {
ast_map::node_foreign_item(_, abi, pt) => {
encode_info_for_foreign_item(ecx, ebml_w, ni,
index, /*bad*/copy *pt,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/tydecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
let len = parse_hex(st);
assert (next(st) == '#');
let key = creader_cache_key { cnum: st.crate, pos: pos, len: len };
match st.tcx.rcache.find(key) {
match st.tcx.rcache.find(&key) {
Some(tt) => return tt,
None => {
let ps = @{pos: pos ,.. copy *st};
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/tyencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn cx_uses_abbrevs(cx: @ctxt) -> bool {
pub fn enc_ty(w: io::Writer, cx: @ctxt, t: ty::t) {
match cx.abbrevs {
ac_no_abbrevs => {
let result_str = match cx.tcx.short_names_cache.find(t) {
let result_str = match cx.tcx.short_names_cache.find(&t) {
Some(s) => /*bad*/copy *s,
None => {
let s = do io::with_str_writer |wr| {
Expand All @@ -69,7 +69,7 @@ pub fn enc_ty(w: io::Writer, cx: @ctxt, t: ty::t) {
w.write_str(result_str);
}
ac_use_abbrevs(abbrevs) => {
match abbrevs.find(t) {
match abbrevs.find(&t) {
Some(a) => { w.write_str(*a.s); return; }
None => {
let pos = w.tell();
Expand Down
28 changes: 14 additions & 14 deletions src/librustc/middle/astencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
debug!("Encoding side tables for id %d", id);
do option::iter(&tcx.def_map.find(id)) |def| {
do option::iter(&tcx.def_map.find(&id)) |def| {
do ebml_w.tag(c::tag_table_def) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
Expand All @@ -855,7 +855,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
}
}
do option::iter(&tcx.node_type_substs.find(id)) |tys| {
do option::iter(&tcx.node_type_substs.find(&id)) |tys| {
do ebml_w.tag(c::tag_table_node_type_subst) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
Expand All @@ -864,7 +864,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
}
}
do option::iter(&tcx.freevars.find(id)) |fv| {
do option::iter(&tcx.freevars.find(&id)) |fv| {
do ebml_w.tag(c::tag_table_freevars) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
Expand All @@ -876,7 +876,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
}
let lid = ast::def_id { crate: ast::local_crate, node: id };
do option::iter(&tcx.tcache.find(lid)) |tpbt| {
do option::iter(&tcx.tcache.find(&lid)) |tpbt| {
do ebml_w.tag(c::tag_table_tcache) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
Expand All @@ -885,7 +885,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
}
}
do option::iter(&tcx.ty_param_bounds.find(id)) |pbs| {
do option::iter(&tcx.ty_param_bounds.find(&id)) |pbs| {
do ebml_w.tag(c::tag_table_param_bounds) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
Expand All @@ -899,7 +899,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
// is what we actually use in trans, all modes will have been
// resolved.
//
//option::iter(tcx.inferred_modes.find(id)) {|m|
//option::iter(tcx.inferred_modes.find(&id)) {|m|
// ebml_w.tag(c::tag_table_inferred_modes) {||
// ebml_w.id(id);
// ebml_w.tag(c::tag_table_val) {||
Expand All @@ -908,13 +908,13 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
// }
//}
do option::iter(&maps.mutbl_map.find(id)) |_m| {
do option::iter(&maps.mutbl_map.find(&id)) |_m| {
do ebml_w.tag(c::tag_table_mutbl) {
ebml_w.id(id);
}
}
do option::iter(&maps.last_use_map.find(id)) |m| {
do option::iter(&maps.last_use_map.find(&id)) |m| {
do ebml_w.tag(c::tag_table_last_use) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
Expand All @@ -925,7 +925,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
}
}
do option::iter(&maps.method_map.find(id)) |mme| {
do option::iter(&maps.method_map.find(&id)) |mme| {
do ebml_w.tag(c::tag_table_method_map) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
Expand All @@ -934,7 +934,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
}
}
do option::iter(&maps.vtable_map.find(id)) |dr| {
do option::iter(&maps.vtable_map.find(&id)) |dr| {
do ebml_w.tag(c::tag_table_vtable_map) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
Expand All @@ -943,7 +943,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
}
}
do option::iter(&tcx.adjustments.find(id)) |adj| {
do option::iter(&tcx.adjustments.find(&id)) |adj| {
do ebml_w.tag(c::tag_table_adjustments) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
Expand All @@ -952,19 +952,19 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
}
}
do option::iter(&tcx.legacy_boxed_traits.find(id)) |_x| {
do option::iter(&tcx.legacy_boxed_traits.find(&id)) |_x| {
do ebml_w.tag(c::tag_table_legacy_boxed_trait) {
ebml_w.id(id);
}
}
for maps.moves_map.find(id).each |_| {
for maps.moves_map.find(&id).each |_| {
do ebml_w.tag(c::tag_table_moves_map) {
ebml_w.id(id);
}
}
for maps.capture_map.find(id).each |cap_vars| {
for maps.capture_map.find(&id).each |cap_vars| {
do ebml_w.tag(c::tag_table_capture_map) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
Expand Down
Loading