oldmap: remove legacy each method
This commit is contained in:
parent
2e496818a5
commit
81b4f36d49
11 changed files with 48 additions and 51 deletions
|
|
@ -833,7 +833,7 @@ pub fn rustc_sysroot() -> ~str {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn install_source(c: &Cargo, path: &Path) {
|
||||
pub fn install_source(c: &mut Cargo, path: &Path) {
|
||||
debug!("source: %s", path.to_str());
|
||||
os::change_dir(path);
|
||||
|
||||
|
|
@ -872,7 +872,8 @@ pub fn install_source(c: &Cargo, path: &Path) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn install_git(c: &Cargo, wd: &Path, url: ~str, reference: Option<~str>) {
|
||||
pub fn install_git(c: &mut Cargo, wd: &Path, url: ~str,
|
||||
reference: Option<~str>) {
|
||||
run::program_output(~"git", ~[~"clone", url, wd.to_str()]);
|
||||
if reference.is_some() {
|
||||
let r = reference.get();
|
||||
|
|
@ -883,7 +884,7 @@ pub fn install_git(c: &Cargo, wd: &Path, url: ~str, reference: Option<~str>) {
|
|||
install_source(c, wd);
|
||||
}
|
||||
|
||||
pub fn install_curl(c: &Cargo, wd: &Path, url: ~str) {
|
||||
pub fn install_curl(c: &mut Cargo, wd: &Path, url: ~str) {
|
||||
let tarpath = wd.push("pkg.tar");
|
||||
let p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o",
|
||||
tarpath.to_str(), url]);
|
||||
|
|
@ -896,14 +897,14 @@ pub fn install_curl(c: &Cargo, wd: &Path, url: ~str) {
|
|||
install_source(c, wd);
|
||||
}
|
||||
|
||||
pub fn install_file(c: &Cargo, wd: &Path, path: &Path) {
|
||||
pub fn install_file(c: &mut Cargo, wd: &Path, path: &Path) {
|
||||
run::program_output(~"tar", ~[~"-x", ~"--strip-components=1",
|
||||
~"-C", wd.to_str(),
|
||||
~"-f", path.to_str()]);
|
||||
install_source(c, wd);
|
||||
}
|
||||
|
||||
pub fn install_package(c: &Cargo, src: ~str, wd: &Path, pkg: Package) {
|
||||
pub fn install_package(c: &mut Cargo, src: ~str, wd: &Path, pkg: Package) {
|
||||
let url = copy pkg.url;
|
||||
let method = match pkg.method {
|
||||
~"git" => ~"git",
|
||||
|
|
@ -930,7 +931,7 @@ pub fn cargo_suggestion(c: &Cargo, fallback: fn()) {
|
|||
fallback();
|
||||
}
|
||||
|
||||
pub fn install_uuid(c: &Cargo, wd: &Path, uuid: ~str) {
|
||||
pub fn install_uuid(c: &mut Cargo, wd: &Path, uuid: ~str) {
|
||||
let mut ps = ~[];
|
||||
for_each_package(c, |s, p| {
|
||||
if p.uuid == uuid {
|
||||
|
|
@ -954,7 +955,7 @@ pub fn install_uuid(c: &Cargo, wd: &Path, uuid: ~str) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn install_named(c: &Cargo, wd: &Path, name: ~str) {
|
||||
pub fn install_named(c: &mut Cargo, wd: &Path, name: ~str) {
|
||||
let mut ps = ~[];
|
||||
for_each_package(c, |s, p| {
|
||||
if p.name == name {
|
||||
|
|
@ -978,7 +979,8 @@ pub fn install_named(c: &Cargo, wd: &Path, name: ~str) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn install_uuid_specific(c: &Cargo, wd: &Path, src: ~str, uuid: ~str) {
|
||||
pub fn install_uuid_specific(c: &mut Cargo, wd: &Path, src: ~str,
|
||||
uuid: ~str) {
|
||||
match c.sources.find(src) {
|
||||
Some(s) => {
|
||||
for s.packages.each |p| {
|
||||
|
|
@ -993,7 +995,8 @@ pub fn install_uuid_specific(c: &Cargo, wd: &Path, src: ~str, uuid: ~str) {
|
|||
error(~"can't find package: " + src + ~"/" + uuid);
|
||||
}
|
||||
|
||||
pub fn install_named_specific(c: &Cargo, wd: &Path, src: ~str, name: ~str) {
|
||||
pub fn install_named_specific(c: &mut Cargo, wd: &Path, src: ~str,
|
||||
name: ~str) {
|
||||
match c.sources.find(src) {
|
||||
Some(s) => {
|
||||
for s.packages.each |p| {
|
||||
|
|
@ -1060,7 +1063,7 @@ pub fn cmd_uninstall(c: &Cargo) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn install_query(c: &Cargo, wd: &Path, target: ~str) {
|
||||
pub fn install_query(c: &mut Cargo, wd: &Path, target: ~str) {
|
||||
match c.dep_cache.find(target) {
|
||||
Some(inst) => {
|
||||
if inst {
|
||||
|
|
@ -1112,10 +1115,7 @@ pub fn install_query(c: &Cargo, wd: &Path, target: ~str) {
|
|||
// a bit of a hack. It should be cleaned up in the future.
|
||||
|
||||
if target == c.current_install {
|
||||
for c.dep_cache.each |k, _v| {
|
||||
c.dep_cache.remove(k);
|
||||
}
|
||||
|
||||
c.dep_cache.clear();
|
||||
c.current_install = ~"";
|
||||
}
|
||||
}
|
||||
|
|
@ -1128,7 +1128,7 @@ pub fn get_temp_workdir(c: &Cargo) -> Path {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn cmd_install(c: &Cargo) {
|
||||
pub fn cmd_install(c: &mut Cargo) {
|
||||
unsafe {
|
||||
let wd = get_temp_workdir(c);
|
||||
|
||||
|
|
@ -1636,7 +1636,7 @@ pub fn dump_sources(c: &Cargo) {
|
|||
result::Ok(writer) => {
|
||||
let mut hash = ~LinearMap::new();
|
||||
|
||||
for c.sources.each |k, v| {
|
||||
for c.sources.each_ref |&k, &v| {
|
||||
let mut chash = ~LinearMap::new();
|
||||
|
||||
chash.insert(~"url", json::String(v.url));
|
||||
|
|
@ -1967,7 +1967,7 @@ pub fn main() {
|
|||
|
||||
match o.free[1] {
|
||||
~"init" => cmd_init(&c),
|
||||
~"install" => cmd_install(&c),
|
||||
~"install" => cmd_install(&mut c),
|
||||
~"uninstall" => cmd_uninstall(&c),
|
||||
~"list" => cmd_list(&c),
|
||||
~"search" => cmd_search(&c),
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ pub fn have_crate_data(cstore: CStore, cnum: ast::crate_num) -> bool {
|
|||
|
||||
pub fn iter_crate_data(cstore: CStore,
|
||||
i: fn(ast::crate_num, crate_metadata)) {
|
||||
for p(cstore).metas.each |k,v| { i(k, v);};
|
||||
for p(cstore).metas.each_ref |&k, &v| { i(k, v);};
|
||||
}
|
||||
|
||||
pub fn add_used_crate_file(cstore: CStore, lib: &Path) {
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ impl LanguageItemCollector {
|
|||
}
|
||||
|
||||
fn check_completeness() {
|
||||
for self.item_refs.each |key, item_ref| {
|
||||
for self.item_refs.each_ref |&key, &item_ref| {
|
||||
match self.items.items[item_ref] {
|
||||
None => {
|
||||
self.session.err(fmt!("no item found for `%s`", key));
|
||||
|
|
|
|||
|
|
@ -400,7 +400,9 @@ pub fn build_settings_crate(sess: session::Session, crate: @ast::crate) {
|
|||
sess: sess});
|
||||
|
||||
// Install defaults.
|
||||
for cx.dict.each |_k, spec| { cx.set_level(spec.lint, spec.default); }
|
||||
for cx.dict.each_value_ref |&spec| {
|
||||
cx.set_level(spec.lint, spec.default);
|
||||
}
|
||||
|
||||
// Install command-line options, overriding defaults.
|
||||
for sess.opts.lint_opts.each |pair| {
|
||||
|
|
|
|||
|
|
@ -833,7 +833,7 @@ pub fn determine_rp_in_crate(sess: Session,
|
|||
|
||||
debug!("%s", {
|
||||
debug!("Region variance results:");
|
||||
for cx.region_paramd_items.each |key, value| {
|
||||
for cx.region_paramd_items.each_ref |&key, &value| {
|
||||
debug!("item %? (%s) is parameterized with variance %?",
|
||||
key,
|
||||
ast_map::node_id_to_str(ast_map, key,
|
||||
|
|
|
|||
|
|
@ -1913,7 +1913,7 @@ pub impl Resolver {
|
|||
self.module_to_str(module_));
|
||||
self.resolve_imports_for_module(module_);
|
||||
|
||||
for module_.children.each |_name, child_node| {
|
||||
for module_.children.each_value_ref |&child_node| {
|
||||
match child_node.get_module_if_available() {
|
||||
None => {
|
||||
// Nothing to do.
|
||||
|
|
@ -1924,7 +1924,7 @@ pub impl Resolver {
|
|||
}
|
||||
}
|
||||
|
||||
for module_.anonymous_children.each |_block_id, child_module| {
|
||||
for module_.anonymous_children.each_value_ref |&child_module| {
|
||||
self.resolve_imports_for_module_subtree(child_module);
|
||||
}
|
||||
}
|
||||
|
|
@ -2430,8 +2430,8 @@ pub impl Resolver {
|
|||
assert containing_module.glob_count == 0;
|
||||
|
||||
// Add all resolved imports from the containing module.
|
||||
for containing_module.import_resolutions.each
|
||||
|ident, target_import_resolution| {
|
||||
for containing_module.import_resolutions.each_ref
|
||||
|&ident, &target_import_resolution| {
|
||||
|
||||
debug!("(resolving glob import) writing module resolution \
|
||||
%? into `%s`",
|
||||
|
|
@ -2480,7 +2480,7 @@ pub impl Resolver {
|
|||
}
|
||||
|
||||
// Add all children from the containing module.
|
||||
for containing_module.children.each |ident, name_bindings| {
|
||||
for containing_module.children.each_ref |&ident, &name_bindings| {
|
||||
let mut dest_import_resolution;
|
||||
match module_.import_resolutions.find(ident) {
|
||||
None => {
|
||||
|
|
@ -3148,7 +3148,7 @@ pub impl Resolver {
|
|||
}
|
||||
|
||||
// Descend into children and anonymous children.
|
||||
for module_.children.each |_name, child_node| {
|
||||
for module_.children.each_value_ref |&child_node| {
|
||||
match child_node.get_module_if_available() {
|
||||
None => {
|
||||
// Continue.
|
||||
|
|
@ -3159,7 +3159,7 @@ pub impl Resolver {
|
|||
}
|
||||
}
|
||||
|
||||
for module_.anonymous_children.each |_name, module_| {
|
||||
for module_.anonymous_children.each_value_ref |&module_| {
|
||||
self.report_unresolved_imports(module_);
|
||||
}
|
||||
}
|
||||
|
|
@ -3204,7 +3204,7 @@ pub impl Resolver {
|
|||
|
||||
self.record_exports_for_module(module_);
|
||||
|
||||
for module_.children.each |_ident, child_name_bindings| {
|
||||
for module_.children.each_value_ref |&child_name_bindings| {
|
||||
match child_name_bindings.get_module_if_available() {
|
||||
None => {
|
||||
// Nothing to do.
|
||||
|
|
@ -3215,7 +3215,7 @@ pub impl Resolver {
|
|||
}
|
||||
}
|
||||
|
||||
for module_.anonymous_children.each |_node_id, child_module| {
|
||||
for module_.anonymous_children.each_value_ref |&child_module| {
|
||||
self.record_exports_for_module_subtree(child_module);
|
||||
}
|
||||
}
|
||||
|
|
@ -4068,7 +4068,7 @@ pub impl Resolver {
|
|||
for arm.pats.eachi() |i, p| {
|
||||
let map_i = self.binding_mode_map(*p);
|
||||
|
||||
for map_0.each |key, binding_0| {
|
||||
for map_0.each_ref |&key, &binding_0| {
|
||||
match map_i.find(key) {
|
||||
None => {
|
||||
self.session.span_err(
|
||||
|
|
@ -4089,7 +4089,7 @@ pub impl Resolver {
|
|||
}
|
||||
}
|
||||
|
||||
for map_i.each |key, binding| {
|
||||
for map_i.each_ref |&key, &binding| {
|
||||
if !map_0.contains_key_ref(&key) {
|
||||
self.session.span_err(
|
||||
binding.span,
|
||||
|
|
@ -5001,7 +5001,7 @@ pub impl Resolver {
|
|||
}
|
||||
|
||||
// Look for trait children.
|
||||
for search_module.children.each |_name, child_name_bindings| {
|
||||
for search_module.children.each_value_ref |&child_name_bindings| {
|
||||
match child_name_bindings.def_for_namespace(TypeNS) {
|
||||
Some(def) => {
|
||||
match def {
|
||||
|
|
@ -5021,8 +5021,8 @@ pub impl Resolver {
|
|||
}
|
||||
|
||||
// Look for imports.
|
||||
for search_module.import_resolutions.each
|
||||
|_ident, import_resolution| {
|
||||
for search_module.import_resolutions.each_value_ref
|
||||
|&import_resolution| {
|
||||
|
||||
match import_resolution.target_for_namespace(TypeNS) {
|
||||
None => {
|
||||
|
|
@ -5184,7 +5184,7 @@ pub impl Resolver {
|
|||
|
||||
self.check_for_unused_imports_in_module(module_);
|
||||
|
||||
for module_.children.each |_ident, child_name_bindings| {
|
||||
for module_.children.each_value_ref |&child_name_bindings| {
|
||||
match (*child_name_bindings).get_module_if_available() {
|
||||
None => {
|
||||
// Nothing to do.
|
||||
|
|
@ -5196,13 +5196,13 @@ pub impl Resolver {
|
|||
}
|
||||
}
|
||||
|
||||
for module_.anonymous_children.each |_node_id, child_module| {
|
||||
for module_.anonymous_children.each_value_ref |&child_module| {
|
||||
self.check_for_unused_imports_in_module_subtree(child_module);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_for_unused_imports_in_module(module_: @Module) {
|
||||
for module_.import_resolutions.each |_name, import_resolution| {
|
||||
for module_.import_resolutions.each_value_ref |&import_resolution| {
|
||||
if !import_resolution.used {
|
||||
match self.unused_import_lint_level {
|
||||
warn => {
|
||||
|
|
@ -5261,12 +5261,12 @@ pub impl Resolver {
|
|||
debug!("Dump of module `%s`:", self.module_to_str(module_));
|
||||
|
||||
debug!("Children:");
|
||||
for module_.children.each |name, _child| {
|
||||
for module_.children.each_key_ref |&name| {
|
||||
debug!("* %s", self.session.str_of(name));
|
||||
}
|
||||
|
||||
debug!("Import resolutions:");
|
||||
for module_.import_resolutions.each |name, import_resolution| {
|
||||
for module_.import_resolutions.each_ref |&name, &import_resolution| {
|
||||
let mut value_repr;
|
||||
match (*import_resolution).target_for_namespace(ValueNS) {
|
||||
None => { value_repr = ~""; }
|
||||
|
|
|
|||
|
|
@ -2806,7 +2806,7 @@ pub fn create_module_map(ccx: @crate_ctxt) -> ValueRef {
|
|||
lib::llvm::SetLinkage(map, lib::llvm::InternalLinkage);
|
||||
}
|
||||
let mut elts: ~[ValueRef] = ~[];
|
||||
for ccx.module_data.each |key, val| {
|
||||
for ccx.module_data.each_ref |&key, &val| {
|
||||
let elt = C_struct(~[p2i(ccx, C_cstr(ccx, key)),
|
||||
p2i(ccx, val)]);
|
||||
elts.push(elt);
|
||||
|
|
@ -3087,7 +3087,7 @@ pub fn trans_crate(sess: session::Session,
|
|||
}
|
||||
|
||||
if ccx.sess.count_llvm_insns() {
|
||||
for ccx.stats.llvm_insns.each |k, v| {
|
||||
for ccx.stats.llvm_insns.each_ref |&k, &v| {
|
||||
io::println(fmt!("%-7u %s", v, k));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -757,7 +757,7 @@ pub fn emit_tydescs(ccx: @crate_ctxt) {
|
|||
let _icx = ccx.insn_ctxt("emit_tydescs");
|
||||
// As of this point, allow no more tydescs to be created.
|
||||
ccx.finished_tydescs = true;
|
||||
for ccx.tydescs.each |_key, val| {
|
||||
for ccx.tydescs.each_value_ref |&val| {
|
||||
let glue_fn_ty = T_ptr(T_generic_glue_fn(ccx));
|
||||
let ti = val;
|
||||
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ Available lint options:
|
|||
padded(max_key, ~"name"), ~"default", ~"meaning"));
|
||||
io::println(fmt!(" %s %7.7s %s\n",
|
||||
padded(max_key, ~"----"), ~"-------", ~"-------"));
|
||||
for lint_dict.each |k, v| {
|
||||
for lint_dict.each_ref |&k, &v| {
|
||||
let k = str::replace(k, ~"_", ~"-");
|
||||
io::println(fmt!(" %s %7.7s %s",
|
||||
padded(max_key, k),
|
||||
|
|
|
|||
|
|
@ -316,10 +316,6 @@ pub mod chained {
|
|||
}
|
||||
}
|
||||
|
||||
pure fn each(blk: fn(key: K, value: V) -> bool) {
|
||||
self.each_ref(|k, v| blk(*k, *v))
|
||||
}
|
||||
|
||||
pure fn each_ref(blk: fn(key: &K, value: &V) -> bool) {
|
||||
for self.each_entry |entry| {
|
||||
if !blk(&entry.key, &entry.value) { break; }
|
||||
|
|
|
|||
|
|
@ -49,10 +49,9 @@ fn sort_and_fmt(mm: HashMap<~[u8], uint>, total: uint) -> ~str {
|
|||
let mut pairs = ~[];
|
||||
|
||||
// map -> [(k,%)]
|
||||
mm.each(fn&(key: ~[u8], val: uint) -> bool {
|
||||
for mm.each_ref |&key, &val| {
|
||||
pairs.push((key, pct(val, total)));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
let pairs_sorted = sortKV(pairs);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue