Skip to content

auto: rm std::map::StdMap trait, rename std::map to std::oldmap and start transition to the core::container::Map API #4746

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 13 commits into from
Feb 4, 2013
Merged
4 changes: 2 additions & 2 deletions doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,10 @@ expression context, the final namespace qualifier is omitted.
Two examples of paths with type arguments:

~~~~
# use std::map;
# use std::oldmap;
# fn f() {
# fn id<T:Copy>(t: T) -> T { t }
type t = map::HashMap<int,~str>; // Type arguments used in a type expression
type t = oldmap::HashMap<int,~str>; // Type arguments used in a type expression
let x = id::<int>(10); // Type arguments used in a call expression
# }
~~~~
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -1791,7 +1791,7 @@ illegal to copy and pass by value.
Generic `type`, `struct`, and `enum` declarations follow the same pattern:

~~~~
# use std::map::HashMap;
# use std::oldmap::HashMap;
type Set<T> = HashMap<T, ()>;

struct Stack<T> {
Expand Down
70 changes: 35 additions & 35 deletions src/libcargo/cargo.rc
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ use core::io::WriterUtil;
use core::result::{Ok, Err};
use core::hashmap::linear::LinearMap;
use std::getopts::{optflag, optopt, opt_present};
use std::map::HashMap;
use std::{map, json, tempfile, term, sort, getopts};
use std::oldmap::HashMap;
use std::{oldmap, json, tempfile, term, sort, getopts};
use syntax::codemap::span;
use syntax::diagnostic::span_handler;
use syntax::diagnostic;
Expand Down Expand Up @@ -110,9 +110,9 @@ pub struct Cargo {
libdir: Path,
workdir: Path,
sourcedir: Path,
sources: map::HashMap<~str, @Source>,
sources: oldmap::HashMap<~str, @Source>,
mut current_install: ~str,
dep_cache: map::HashMap<~str, bool>,
dep_cache: oldmap::HashMap<~str, bool>,
opts: Options
}

Expand Down Expand Up @@ -490,7 +490,7 @@ pub fn parse_source(name: ~str, j: &json::Json) -> @Source {
}

pub fn try_parse_sources(filename: &Path,
sources: map::HashMap<~str, @Source>) {
sources: oldmap::HashMap<~str, @Source>) {
if !os::path_exists(filename) { return; }
let c = io::read_whole_file_str(filename);
match json::from_str(c.get()) {
Expand Down Expand Up @@ -730,7 +730,7 @@ pub fn configure(opts: Options) -> Cargo {
need_dir(&c.libdir);
need_dir(&c.bindir);

for sources.each_key |k| {
for sources.each_key_ref |&k| {
let mut s = sources.get(k);
load_source_packages(&c, s);
sources.insert(k, s);
Expand All @@ -748,7 +748,7 @@ pub fn configure(opts: Options) -> Cargo {
}

pub fn for_each_package(c: &Cargo, b: fn(s: @Source, p: &Package)) {
for c.sources.each_value |v| {
for c.sources.each_value_ref |&v| {
for v.packages.each |p| {
b(v, p);
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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();
Expand All @@ -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]);
Expand All @@ -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",
Expand All @@ -922,15 +923,15 @@ pub fn install_package(c: &Cargo, src: ~str, wd: &Path, pkg: Package) {
}

pub fn cargo_suggestion(c: &Cargo, fallback: fn()) {
if c.sources.size() == 0u {
if c.sources.is_empty() {
error(~"no sources defined - you may wish to run " +
~"`cargo init`");
return;
}
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 {
Expand All @@ -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 {
Expand All @@ -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| {
Expand All @@ -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| {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 = ~"";
}
}
Expand All @@ -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);

Expand All @@ -1155,7 +1155,7 @@ pub fn cmd_install(c: &Cargo) {
}

pub fn sync(c: &Cargo) {
for c.sources.each_key |k| {
for c.sources.each_key_ref |&k| {
let mut s = c.sources.get(k);
sync_one(c, s);
c.sources.insert(k, s);
Expand Down Expand Up @@ -1569,7 +1569,7 @@ pub fn cmd_list(c: &Cargo) {
}
}
} else {
for c.sources.each_value |v| {
for c.sources.each_value_ref |&v| {
print_source(v);
}
}
Expand Down Expand Up @@ -1620,7 +1620,7 @@ pub fn dump_cache(c: &Cargo) {
}

pub fn dump_sources(c: &Cargo) {
if c.sources.size() < 1u {
if c.sources.is_empty() {
return;
}

Expand All @@ -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));
Expand Down Expand Up @@ -1675,7 +1675,7 @@ pub fn copy_warn(srcfile: &Path, destfile: &Path) {

pub fn cmd_sources(c: &Cargo) {
if vec::len(c.opts.free) < 3u {
for c.sources.each_value |v| {
for c.sources.each_value_ref |&v| {
info(fmt!("%s (%s) via %s",
v.name, v.url, v.method));
}
Expand All @@ -1686,8 +1686,8 @@ pub fn cmd_sources(c: &Cargo) {

match action {
~"clear" => {
for c.sources.each_key |k| {
c.sources.remove(k);
for c.sources.each_key_ref |&k| {
c.sources.remove(&k);
}

info(~"cleared sources");
Expand All @@ -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 {
Expand All @@ -1733,8 +1733,8 @@ pub fn cmd_sources(c: &Cargo) {
return;
}

if c.sources.contains_key(name) {
c.sources.remove(name);
if c.sources.contains_key_ref(&name) {
c.sources.remove(&name);
info(fmt!("removed source: %s", name));
} else {
error(fmt!("no such source: %s", name));
Expand Down Expand Up @@ -1825,7 +1825,7 @@ pub fn cmd_sources(c: &Cargo) {

match c.sources.find(name) {
Some(source) => {
c.sources.remove(name);
c.sources.remove(&name);
c.sources.insert(newn, source);
info(fmt!("renamed source: %s to %s", name, newn));
}
Expand Down Expand Up @@ -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),
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 @@ -36,7 +36,7 @@ use core::ptr;
use core::run;
use core::str;
use core::vec;
use std::map::HashMap;
use std::oldmap::HashMap;
use std::sha1::sha1;
use syntax::ast;
use syntax::ast_map::{path, path_mod, path_name};
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/back/rpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use core::os;
use core::uint;
use core::util;
use core::vec;
use std::map::HashMap;
use std::map;
use std::oldmap::HashMap;
use std::oldmap;

pure fn not_win32(os: session::os) -> bool {
match os {
Expand Down Expand Up @@ -187,7 +187,7 @@ pub fn get_install_prefix_rpath(target_triple: &str) -> Path {
}

pub fn minimize_rpaths(rpaths: &[Path]) -> ~[Path] {
let set = map::HashMap();
let set = oldmap::HashMap();
let mut minimized = ~[];
for rpaths.each |rpath| {
let s = rpath.to_str();
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 @@ -35,7 +35,7 @@ use std::getopts::groups::{optopt, optmulti, optflag, optflagopt, getopts};
use std::getopts::groups;
use std::getopts::{opt_present};
use std::getopts;
use std::map::HashMap;
use std::oldmap::HashMap;
use std;
use syntax::ast;
use syntax::ast_map;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lib/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use core::ptr;
use core::str;
use core::uint;
use core::vec;
use std::map::HashMap;
use std::oldmap::HashMap;

pub type Opcode = u32;
pub type Bool = c_uint;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use syntax::parse::token::ident_interner;
use syntax::print::pprust;
use syntax::visit;
use syntax::{ast, ast_util};
use std::map::HashMap;
use std::oldmap::HashMap;

// Traverses an AST, reading all the information about use'd crates and extern
// libraries necessary for later resolving, typechecking, linking, etc.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/csearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use core::dvec::DVec;
use core::vec;
use reader = std::ebml::reader;
use std::ebml;
use std::map::HashMap;
use std::oldmap::HashMap;
use syntax::ast;
use syntax::ast_map;
use syntax::codemap::dummy_sp;
Expand Down
Loading