Skip to content

Commit 81b4f36

Browse files
committed
oldmap: remove legacy each method
1 parent 2e49681 commit 81b4f36

File tree

11 files changed

+48
-51
lines changed

11 files changed

+48
-51
lines changed

src/libcargo/cargo.rc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ pub fn rustc_sysroot() -> ~str {
833833
}
834834
}
835835

836-
pub fn install_source(c: &Cargo, path: &Path) {
836+
pub fn install_source(c: &mut Cargo, path: &Path) {
837837
debug!("source: %s", path.to_str());
838838
os::change_dir(path);
839839

@@ -872,7 +872,8 @@ pub fn install_source(c: &Cargo, path: &Path) {
872872
}
873873
}
874874

875-
pub fn install_git(c: &Cargo, wd: &Path, url: ~str, reference: Option<~str>) {
875+
pub fn install_git(c: &mut Cargo, wd: &Path, url: ~str,
876+
reference: Option<~str>) {
876877
run::program_output(~"git", ~[~"clone", url, wd.to_str()]);
877878
if reference.is_some() {
878879
let r = reference.get();
@@ -883,7 +884,7 @@ pub fn install_git(c: &Cargo, wd: &Path, url: ~str, reference: Option<~str>) {
883884
install_source(c, wd);
884885
}
885886

886-
pub fn install_curl(c: &Cargo, wd: &Path, url: ~str) {
887+
pub fn install_curl(c: &mut Cargo, wd: &Path, url: ~str) {
887888
let tarpath = wd.push("pkg.tar");
888889
let p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o",
889890
tarpath.to_str(), url]);
@@ -896,14 +897,14 @@ pub fn install_curl(c: &Cargo, wd: &Path, url: ~str) {
896897
install_source(c, wd);
897898
}
898899

899-
pub fn install_file(c: &Cargo, wd: &Path, path: &Path) {
900+
pub fn install_file(c: &mut Cargo, wd: &Path, path: &Path) {
900901
run::program_output(~"tar", ~[~"-x", ~"--strip-components=1",
901902
~"-C", wd.to_str(),
902903
~"-f", path.to_str()]);
903904
install_source(c, wd);
904905
}
905906

906-
pub fn install_package(c: &Cargo, src: ~str, wd: &Path, pkg: Package) {
907+
pub fn install_package(c: &mut Cargo, src: ~str, wd: &Path, pkg: Package) {
907908
let url = copy pkg.url;
908909
let method = match pkg.method {
909910
~"git" => ~"git",
@@ -930,7 +931,7 @@ pub fn cargo_suggestion(c: &Cargo, fallback: fn()) {
930931
fallback();
931932
}
932933

933-
pub fn install_uuid(c: &Cargo, wd: &Path, uuid: ~str) {
934+
pub fn install_uuid(c: &mut Cargo, wd: &Path, uuid: ~str) {
934935
let mut ps = ~[];
935936
for_each_package(c, |s, p| {
936937
if p.uuid == uuid {
@@ -954,7 +955,7 @@ pub fn install_uuid(c: &Cargo, wd: &Path, uuid: ~str) {
954955
}
955956
}
956957

957-
pub fn install_named(c: &Cargo, wd: &Path, name: ~str) {
958+
pub fn install_named(c: &mut Cargo, wd: &Path, name: ~str) {
958959
let mut ps = ~[];
959960
for_each_package(c, |s, p| {
960961
if p.name == name {
@@ -978,7 +979,8 @@ pub fn install_named(c: &Cargo, wd: &Path, name: ~str) {
978979
}
979980
}
980981

981-
pub fn install_uuid_specific(c: &Cargo, wd: &Path, src: ~str, uuid: ~str) {
982+
pub fn install_uuid_specific(c: &mut Cargo, wd: &Path, src: ~str,
983+
uuid: ~str) {
982984
match c.sources.find(src) {
983985
Some(s) => {
984986
for s.packages.each |p| {
@@ -993,7 +995,8 @@ pub fn install_uuid_specific(c: &Cargo, wd: &Path, src: ~str, uuid: ~str) {
993995
error(~"can't find package: " + src + ~"/" + uuid);
994996
}
995997

996-
pub fn install_named_specific(c: &Cargo, wd: &Path, src: ~str, name: ~str) {
998+
pub fn install_named_specific(c: &mut Cargo, wd: &Path, src: ~str,
999+
name: ~str) {
9971000
match c.sources.find(src) {
9981001
Some(s) => {
9991002
for s.packages.each |p| {
@@ -1060,7 +1063,7 @@ pub fn cmd_uninstall(c: &Cargo) {
10601063
}
10611064
}
10621065

1063-
pub fn install_query(c: &Cargo, wd: &Path, target: ~str) {
1066+
pub fn install_query(c: &mut Cargo, wd: &Path, target: ~str) {
10641067
match c.dep_cache.find(target) {
10651068
Some(inst) => {
10661069
if inst {
@@ -1112,10 +1115,7 @@ pub fn install_query(c: &Cargo, wd: &Path, target: ~str) {
11121115
// a bit of a hack. It should be cleaned up in the future.
11131116

11141117
if target == c.current_install {
1115-
for c.dep_cache.each |k, _v| {
1116-
c.dep_cache.remove(k);
1117-
}
1118-
1118+
c.dep_cache.clear();
11191119
c.current_install = ~"";
11201120
}
11211121
}
@@ -1128,7 +1128,7 @@ pub fn get_temp_workdir(c: &Cargo) -> Path {
11281128
}
11291129
}
11301130

1131-
pub fn cmd_install(c: &Cargo) {
1131+
pub fn cmd_install(c: &mut Cargo) {
11321132
unsafe {
11331133
let wd = get_temp_workdir(c);
11341134

@@ -1636,7 +1636,7 @@ pub fn dump_sources(c: &Cargo) {
16361636
result::Ok(writer) => {
16371637
let mut hash = ~LinearMap::new();
16381638

1639-
for c.sources.each |k, v| {
1639+
for c.sources.each_ref |&k, &v| {
16401640
let mut chash = ~LinearMap::new();
16411641

16421642
chash.insert(~"url", json::String(v.url));
@@ -1967,7 +1967,7 @@ pub fn main() {
19671967

19681968
match o.free[1] {
19691969
~"init" => cmd_init(&c),
1970-
~"install" => cmd_install(&c),
1970+
~"install" => cmd_install(&mut c),
19711971
~"uninstall" => cmd_uninstall(&c),
19721972
~"list" => cmd_list(&c),
19731973
~"search" => cmd_search(&c),

src/librustc/metadata/cstore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub fn have_crate_data(cstore: CStore, cnum: ast::crate_num) -> bool {
9999

100100
pub fn iter_crate_data(cstore: CStore,
101101
i: fn(ast::crate_num, crate_metadata)) {
102-
for p(cstore).metas.each |k,v| { i(k, v);};
102+
for p(cstore).metas.each_ref |&k, &v| { i(k, v);};
103103
}
104104

105105
pub fn add_used_crate_file(cstore: CStore, lib: &Path) {

src/librustc/middle/lang_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ impl LanguageItemCollector {
391391
}
392392

393393
fn check_completeness() {
394-
for self.item_refs.each |key, item_ref| {
394+
for self.item_refs.each_ref |&key, &item_ref| {
395395
match self.items.items[item_ref] {
396396
None => {
397397
self.session.err(fmt!("no item found for `%s`", key));

src/librustc/middle/lint.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,9 @@ pub fn build_settings_crate(sess: session::Session, crate: @ast::crate) {
400400
sess: sess});
401401

402402
// Install defaults.
403-
for cx.dict.each |_k, spec| { cx.set_level(spec.lint, spec.default); }
403+
for cx.dict.each_value_ref |&spec| {
404+
cx.set_level(spec.lint, spec.default);
405+
}
404406

405407
// Install command-line options, overriding defaults.
406408
for sess.opts.lint_opts.each |pair| {

src/librustc/middle/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ pub fn determine_rp_in_crate(sess: Session,
833833

834834
debug!("%s", {
835835
debug!("Region variance results:");
836-
for cx.region_paramd_items.each |key, value| {
836+
for cx.region_paramd_items.each_ref |&key, &value| {
837837
debug!("item %? (%s) is parameterized with variance %?",
838838
key,
839839
ast_map::node_id_to_str(ast_map, key,

src/librustc/middle/resolve.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,7 @@ pub impl Resolver {
19131913
self.module_to_str(module_));
19141914
self.resolve_imports_for_module(module_);
19151915

1916-
for module_.children.each |_name, child_node| {
1916+
for module_.children.each_value_ref |&child_node| {
19171917
match child_node.get_module_if_available() {
19181918
None => {
19191919
// Nothing to do.
@@ -1924,7 +1924,7 @@ pub impl Resolver {
19241924
}
19251925
}
19261926

1927-
for module_.anonymous_children.each |_block_id, child_module| {
1927+
for module_.anonymous_children.each_value_ref |&child_module| {
19281928
self.resolve_imports_for_module_subtree(child_module);
19291929
}
19301930
}
@@ -2430,8 +2430,8 @@ pub impl Resolver {
24302430
assert containing_module.glob_count == 0;
24312431
24322432
// Add all resolved imports from the containing module.
2433-
for containing_module.import_resolutions.each
2434-
|ident, target_import_resolution| {
2433+
for containing_module.import_resolutions.each_ref
2434+
|&ident, &target_import_resolution| {
24352435
24362436
debug!("(resolving glob import) writing module resolution \
24372437
%? into `%s`",
@@ -2480,7 +2480,7 @@ pub impl Resolver {
24802480
}
24812481

24822482
// Add all children from the containing module.
2483-
for containing_module.children.each |ident, name_bindings| {
2483+
for containing_module.children.each_ref |&ident, &name_bindings| {
24842484
let mut dest_import_resolution;
24852485
match module_.import_resolutions.find(ident) {
24862486
None => {
@@ -3148,7 +3148,7 @@ pub impl Resolver {
31483148
}
31493149

31503150
// Descend into children and anonymous children.
3151-
for module_.children.each |_name, child_node| {
3151+
for module_.children.each_value_ref |&child_node| {
31523152
match child_node.get_module_if_available() {
31533153
None => {
31543154
// Continue.
@@ -3159,7 +3159,7 @@ pub impl Resolver {
31593159
}
31603160
}
31613161

3162-
for module_.anonymous_children.each |_name, module_| {
3162+
for module_.anonymous_children.each_value_ref |&module_| {
31633163
self.report_unresolved_imports(module_);
31643164
}
31653165
}
@@ -3204,7 +3204,7 @@ pub impl Resolver {
32043204

32053205
self.record_exports_for_module(module_);
32063206

3207-
for module_.children.each |_ident, child_name_bindings| {
3207+
for module_.children.each_value_ref |&child_name_bindings| {
32083208
match child_name_bindings.get_module_if_available() {
32093209
None => {
32103210
// Nothing to do.
@@ -3215,7 +3215,7 @@ pub impl Resolver {
32153215
}
32163216
}
32173217

3218-
for module_.anonymous_children.each |_node_id, child_module| {
3218+
for module_.anonymous_children.each_value_ref |&child_module| {
32193219
self.record_exports_for_module_subtree(child_module);
32203220
}
32213221
}
@@ -4068,7 +4068,7 @@ pub impl Resolver {
40684068
for arm.pats.eachi() |i, p| {
40694069
let map_i = self.binding_mode_map(*p);
40704070

4071-
for map_0.each |key, binding_0| {
4071+
for map_0.each_ref |&key, &binding_0| {
40724072
match map_i.find(key) {
40734073
None => {
40744074
self.session.span_err(
@@ -4089,7 +4089,7 @@ pub impl Resolver {
40894089
}
40904090
}
40914091

4092-
for map_i.each |key, binding| {
4092+
for map_i.each_ref |&key, &binding| {
40934093
if !map_0.contains_key_ref(&key) {
40944094
self.session.span_err(
40954095
binding.span,
@@ -5001,7 +5001,7 @@ pub impl Resolver {
50015001
}
50025002

50035003
// Look for trait children.
5004-
for search_module.children.each |_name, child_name_bindings| {
5004+
for search_module.children.each_value_ref |&child_name_bindings| {
50055005
match child_name_bindings.def_for_namespace(TypeNS) {
50065006
Some(def) => {
50075007
match def {
@@ -5021,8 +5021,8 @@ pub impl Resolver {
50215021
}
50225022

50235023
// Look for imports.
5024-
for search_module.import_resolutions.each
5025-
|_ident, import_resolution| {
5024+
for search_module.import_resolutions.each_value_ref
5025+
|&import_resolution| {
50265026

50275027
match import_resolution.target_for_namespace(TypeNS) {
50285028
None => {
@@ -5184,7 +5184,7 @@ pub impl Resolver {
51845184

51855185
self.check_for_unused_imports_in_module(module_);
51865186

5187-
for module_.children.each |_ident, child_name_bindings| {
5187+
for module_.children.each_value_ref |&child_name_bindings| {
51885188
match (*child_name_bindings).get_module_if_available() {
51895189
None => {
51905190
// Nothing to do.
@@ -5196,13 +5196,13 @@ pub impl Resolver {
51965196
}
51975197
}
51985198

5199-
for module_.anonymous_children.each |_node_id, child_module| {
5199+
for module_.anonymous_children.each_value_ref |&child_module| {
52005200
self.check_for_unused_imports_in_module_subtree(child_module);
52015201
}
52025202
}
52035203

52045204
fn check_for_unused_imports_in_module(module_: @Module) {
5205-
for module_.import_resolutions.each |_name, import_resolution| {
5205+
for module_.import_resolutions.each_value_ref |&import_resolution| {
52065206
if !import_resolution.used {
52075207
match self.unused_import_lint_level {
52085208
warn => {
@@ -5261,12 +5261,12 @@ pub impl Resolver {
52615261
debug!("Dump of module `%s`:", self.module_to_str(module_));
52625262

52635263
debug!("Children:");
5264-
for module_.children.each |name, _child| {
5264+
for module_.children.each_key_ref |&name| {
52655265
debug!("* %s", self.session.str_of(name));
52665266
}
52675267

52685268
debug!("Import resolutions:");
5269-
for module_.import_resolutions.each |name, import_resolution| {
5269+
for module_.import_resolutions.each_ref |&name, &import_resolution| {
52705270
let mut value_repr;
52715271
match (*import_resolution).target_for_namespace(ValueNS) {
52725272
None => { value_repr = ~""; }

src/librustc/middle/trans/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,7 +2806,7 @@ pub fn create_module_map(ccx: @crate_ctxt) -> ValueRef {
28062806
lib::llvm::SetLinkage(map, lib::llvm::InternalLinkage);
28072807
}
28082808
let mut elts: ~[ValueRef] = ~[];
2809-
for ccx.module_data.each |key, val| {
2809+
for ccx.module_data.each_ref |&key, &val| {
28102810
let elt = C_struct(~[p2i(ccx, C_cstr(ccx, key)),
28112811
p2i(ccx, val)]);
28122812
elts.push(elt);
@@ -3087,7 +3087,7 @@ pub fn trans_crate(sess: session::Session,
30873087
}
30883088
30893089
if ccx.sess.count_llvm_insns() {
3090-
for ccx.stats.llvm_insns.each |k, v| {
3090+
for ccx.stats.llvm_insns.each_ref |&k, &v| {
30913091
io::println(fmt!("%-7u %s", v, k));
30923092
}
30933093
}

src/librustc/middle/trans/glue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ pub fn emit_tydescs(ccx: @crate_ctxt) {
757757
let _icx = ccx.insn_ctxt("emit_tydescs");
758758
// As of this point, allow no more tydescs to be created.
759759
ccx.finished_tydescs = true;
760-
for ccx.tydescs.each |_key, val| {
760+
for ccx.tydescs.each_value_ref |&val| {
761761
let glue_fn_ty = T_ptr(T_generic_glue_fn(ccx));
762762
let ti = val;
763763

src/librustc/rustc.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Available lint options:
186186
padded(max_key, ~"name"), ~"default", ~"meaning"));
187187
io::println(fmt!(" %s %7.7s %s\n",
188188
padded(max_key, ~"----"), ~"-------", ~"-------"));
189-
for lint_dict.each |k, v| {
189+
for lint_dict.each_ref |&k, &v| {
190190
let k = str::replace(k, ~"_", ~"-");
191191
io::println(fmt!(" %s %7.7s %s",
192192
padded(max_key, k),

src/libstd/oldmap.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,6 @@ pub mod chained {
316316
}
317317
}
318318

319-
pure fn each(blk: fn(key: K, value: V) -> bool) {
320-
self.each_ref(|k, v| blk(*k, *v))
321-
}
322-
323319
pure fn each_ref(blk: fn(key: &K, value: &V) -> bool) {
324320
for self.each_entry |entry| {
325321
if !blk(&entry.key, &entry.value) { break; }

src/test/bench/shootout-k-nucleotide-pipes.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ fn sort_and_fmt(mm: HashMap<~[u8], uint>, total: uint) -> ~str {
4949
let mut pairs = ~[];
5050

5151
// map -> [(k,%)]
52-
mm.each(fn&(key: ~[u8], val: uint) -> bool {
52+
for mm.each_ref |&key, &val| {
5353
pairs.push((key, pct(val, total)));
54-
return true;
55-
});
54+
}
5655

5756
let pairs_sorted = sortKV(pairs);
5857

0 commit comments

Comments
 (0)