diff --git a/libs/hamcrest-rust b/libs/hamcrest-rust index add50d98e..de700414a 160000 --- a/libs/hamcrest-rust +++ b/libs/hamcrest-rust @@ -1 +1 @@ -Subproject commit add50d98e97ef30e7264ae70b83cf5ddedbf4450 +Subproject commit de700414aab1aaa4461618ce7a516cb24a8e6665 diff --git a/libs/rust-toml b/libs/rust-toml index 1702321fb..e248cfbd6 160000 --- a/libs/rust-toml +++ b/libs/rust-toml @@ -1 +1 @@ -Subproject commit 1702321fb1300aaf4182f4ba48d31f8eaf0a5a69 +Subproject commit e248cfbd6e336c3ea1a7273bea66e2fd3e3591f6 diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index 36c620cc7..08b366b89 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -31,14 +31,14 @@ fn execute() { Err(err) => return handle_error(err) }; - if cmd == ~"config-for-key" { execute_main_without_stdin(config_for_key) } - else if cmd == ~"config-list" { execute_main_without_stdin(config_list) } - else if cmd == ~"locate-project" { execute_main_without_stdin(locate_project) } + if cmd == "config-for-key".to_owned() { execute_main_without_stdin(config_for_key) } + else if cmd == "config-list".to_owned() { execute_main_without_stdin(config_list) } + else if cmd == "locate-project".to_owned() { execute_main_without_stdin(locate_project) } } fn process(mut args: ~[~str]) -> CargoResult<(~str, ~[~str])> { args = args.tail().to_owned(); - let head = try!(args.head().to_cargo_error(~"No subcommand found", 1)).to_owned(); + let head = try!(args.head().to_cargo_error("No subcommand found".to_owned(), 1)).to_owned(); let tail = args.tail().to_owned(); Ok((head, tail)) @@ -99,7 +99,7 @@ fn config_list(args: ConfigListFlags) -> CargoResult> { } fn locate_project(_: NoFlags) -> CargoResult> { - let root = try!(find_project(os::getcwd(), ~"Cargo.toml")); + let root = try!(find_project(os::getcwd(), "Cargo.toml".to_owned())); let string = try!(root.as_str().to_cargo_error(format!("Your project path contains characters not representable in Unicode: {}", os::getcwd().display()), 1)); Ok(Some(ProjectLocation { root: string.to_owned() })) } diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index 59b02368f..67660a229 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -52,7 +52,7 @@ impl Manifest { project: project.clone(), lib: lib, bin: bin, - target: ~"target", + target: "target".to_owned(), dependencies: deps }) } diff --git a/src/cargo/mod.rs b/src/cargo/mod.rs index 3dc7e22be..77653915f 100644 --- a/src/cargo/mod.rs +++ b/src/cargo/mod.rs @@ -146,7 +146,7 @@ fn flags_from_args() -> CargoResult { fn json_from_stdin() -> CargoResult { let mut reader = io::stdin(); - let input = try!(reader.read_to_str().to_cargo_error(~"Cannot read stdin to a string", 1)); + let input = try!(reader.read_to_str().to_cargo_error("Cannot read stdin to a string".to_owned(), 1)); let json = try!(json::from_str(input).to_cargo_error(format!("Cannot parse json: {}", input), 1)); let mut decoder = json::Decoder::new(json); diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 925800d1a..3c258289f 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -34,24 +34,15 @@ use sources::path::PathSource; use ops::cargo_rustc; use {CargoError,ToCargoError,CargoResult}; -#[deriving(Decodable)] -struct Options { - manifest_path: ~str -} -impl FlagConfig for Options { - fn config(_: Option, c: FlagConfiguration) -> FlagConfiguration { c } -} - -pub fn compile() -> CargoResult<()> { - let options = try!(flags::()); - let manifest = try!(cargo_read_manifest(options.manifest_path)); +pub fn compile(manifest_path: &str) -> CargoResult<()> { + let manifest = try!(cargo_read_manifest(manifest_path)); let configs = try!(all_configs(os::getcwd())); - let config_paths = configs.find(&~"paths").map(|v| v.clone()).unwrap_or_else(|| ConfigValue::new()); + let config_paths = configs.find(&("paths".to_owned())).map(|v| v.clone()).unwrap_or_else(|| ConfigValue::new()); let paths = match config_paths.get_value() { - &config::String(_) => return Err(CargoError::new(~"The path was configured as a String instead of a List", 1)), + &config::String(_) => return Err(CargoError::new("The path was configured as a String instead of a List".to_owned(), 1)), &config::List(ref list) => list.iter().map(|path| Path::new(path.as_slice())).collect() }; @@ -74,13 +65,9 @@ pub fn compile() -> CargoResult<()> { //call_rustc(~BufReader::new(manifest_bytes.as_slice())) } -fn flags>() -> CargoResult { - let mut decoder = FlagDecoder::new::(std::os::args().tail()); - Decodable::decode(&mut decoder).to_cargo_error(|e: HammerError| e.message, 1) -} fn read_manifest(manifest_path: &str) -> CargoResult> { - Ok((try!(exec_with_output("cargo-read-manifest", [~"--manifest-path", manifest_path.to_owned()], None))).output) + Ok((try!(exec_with_output("cargo-read-manifest", ["--manifest-path".to_owned(), manifest_path.to_owned()], None))).output) } fn call_rustc(mut manifest_data: ~Reader:) -> CargoResult<()> { diff --git a/src/cargo/ops/cargo_rustc.rs b/src/cargo/ops/cargo_rustc.rs index 39c410efa..c2c51a5e1 100644 --- a/src/cargo/ops/cargo_rustc.rs +++ b/src/cargo/ops/cargo_rustc.rs @@ -51,9 +51,9 @@ fn rustc(root: &Path, src: &Path, target: &Path, deps: &[core::Package]) { fn build_base_args(dst: &mut Args, src: &Path, target: &Path) { dst.push(src.as_str().unwrap().to_owned()); - dst.push(~"--crate-type"); - dst.push(~"lib"); - dst.push(~"--out-dir"); + dst.push("--crate-type".to_owned()); + dst.push("lib".to_owned()); + dst.push("--out-dir".to_owned()); dst.push(target.as_str().unwrap().to_owned()); } @@ -61,7 +61,7 @@ fn build_deps_args(dst: &mut Args, deps: &[core::Package]) { for dep in deps.iter() { let target = dep.get_root().join(Path::new(dep.get_target())); - dst.push(~"-L"); + dst.push("-L".to_owned()); dst.push(target.as_str().unwrap().to_owned()); } } @@ -76,20 +76,20 @@ pub fn execute(_: NoFlags, manifest: core::Manifest) -> CargoResult 0 { - ( ~"lib", lib[0].path ) + ( "lib".to_owned(), lib[0].path ) } else if bin.len() > 0 { - ( ~"bin", bin[0].path ) + ( "bin".to_owned(), bin[0].path ) } else { - return Err(CargoError::new(~"bad manifest, no lib or bin specified", 1)); + return Err(CargoError::new("bad manifest, no lib or bin specified".to_owned(), 1)); }; let root = Path::new(root); - let target = join(&root, ~"target"); + let target = join(&root, "target".to_owned()); let args = [ join(&root, out_dir), - ~"--out-dir", target, - ~"--crate-type", crate_type + "--out-dir".to_owned(), target, + "--crate-type".to_owned(), crate_type ]; match io::fs::mkdir_recursive(&root.join("target"), io::UserRWX) { diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index bd572d832..c241199ac 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -99,7 +99,7 @@ fn find_in_tree(pwd: &Path, walk: |io::fs::File| -> CargoResult) -> CargoR loop { let possible = current.join(".cargo").join("config"); if possible.exists() { - let file = try!(io::fs::File::open(&possible).to_cargo_error(~"", 1)); + let file = try!(io::fs::File::open(&possible).to_cargo_error("".to_owned(), 1)); match walk(file) { Ok(res) => return Ok(res), _ => () @@ -109,7 +109,7 @@ fn find_in_tree(pwd: &Path, walk: |io::fs::File| -> CargoResult) -> CargoR if !current.pop() { break; } } - Err(CargoError::new(~"", 1)) + Err(CargoError::new("".to_owned(), 1)) } fn walk_tree(pwd: &Path, walk: |io::fs::File| -> CargoResult<()>) -> CargoResult<()> { @@ -119,14 +119,14 @@ fn walk_tree(pwd: &Path, walk: |io::fs::File| -> CargoResult<()>) -> CargoResult loop { let possible = current.join(".cargo").join("config"); if possible.exists() { - let file = try!(io::fs::File::open(&possible).to_cargo_error(~"", 1)); + let file = try!(io::fs::File::open(&possible).to_cargo_error("".to_owned(), 1)); match walk(file) { Err(_) => err = false, _ => () } } - if err { return Err(CargoError::new(~"", 1)); } + if err { return Err(CargoError::new("".to_owned(), 1)); } if !current.pop() { break; } } @@ -134,25 +134,25 @@ fn walk_tree(pwd: &Path, walk: |io::fs::File| -> CargoResult<()>) -> CargoResult } fn extract_config(file: io::fs::File, key: &str) -> CargoResult { - let path = try!(file.path().as_str().to_cargo_error(~"", 1)).to_owned(); + let path = try!(file.path().as_str().to_cargo_error("".to_owned(), 1)).to_owned(); let mut buf = io::BufferedReader::new(file); - let root = try!(toml::parse_from_buffer(&mut buf).to_cargo_error(~"", 1)); - let val = try!(root.lookup(key).to_cargo_error(~"", 1)); + let root = try!(toml::parse_from_buffer(&mut buf).to_cargo_error("".to_owned(), 1)); + let val = try!(root.lookup(key).to_cargo_error("".to_owned(), 1)); let v = match val { &toml::String(ref val) => String(val.to_owned()), &toml::Array(ref val) => List(val.iter().map(|s: &toml::Value| s.to_str()).collect()), - _ => return Err(CargoError::new(~"", 1)) + _ => return Err(CargoError::new("".to_owned(), 1)) }; Ok(ConfigValue{ value: v, path: vec!(path) }) } fn extract_all_configs(file: io::fs::File, map: &mut collections::HashMap<~str, ConfigValue>) -> CargoResult<()> { - let path = try!(file.path().as_str().to_cargo_error(~"", 1)).to_owned(); + let path = try!(file.path().as_str().to_cargo_error("".to_owned(), 1)).to_owned(); let mut buf = io::BufferedReader::new(file); - let root = try!(toml::parse_from_buffer(&mut buf).to_cargo_error(~"", 1)); - let table = try!(root.get_table().to_cargo_error(~"", 1)); + let root = try!(toml::parse_from_buffer(&mut buf).to_cargo_error("".to_owned(), 1)); + let table = try!(root.get_table().to_cargo_error("".to_owned(), 1)); for (key, value) in table.iter() { match value { @@ -173,11 +173,11 @@ fn extract_all_configs(file: io::fs::File, map: &mut collections::HashMap<~str, fn merge_array(existing: &mut ConfigValue, val: &[toml::Value], path: &str) -> CargoResult<()> { match existing.value { - String(_) => return Err(CargoError::new(~"", 1)), + String(_) => return Err(CargoError::new("".to_owned(), 1)), List(ref mut list) => { let new_list: Vec> = val.iter().map(|s: &toml::Value| toml_string(s)).collect(); if new_list.iter().any(|v| v.is_err()) { - return Err(CargoError::new(~"", 1)); + return Err(CargoError::new("".to_owned(), 1)); } else { let new_list: Vec<~str> = new_list.move_iter().map(|v| v.unwrap()).collect(); list.push_all(new_list.as_slice()); @@ -191,6 +191,6 @@ fn merge_array(existing: &mut ConfigValue, val: &[toml::Value], path: &str) -> C fn toml_string(val: &toml::Value) -> CargoResult<~str> { match val { &toml::String(ref str) => Ok(str.to_owned()), - _ => Err(CargoError::new(~"", 1)) + _ => Err(CargoError::new("".to_owned(), 1)) } } diff --git a/src/cargo/util/process_builder.rs b/src/cargo/util/process_builder.rs index c1c1348a3..e51129066 100644 --- a/src/cargo/util/process_builder.rs +++ b/src/cargo/util/process_builder.rs @@ -67,15 +67,15 @@ impl ProcessBuilder { config.args = self.args.as_slice(); config.cwd = Some(&self.cwd); - let os_path = try!(os::getenv("PATH").to_cargo_error(~"Could not find the PATH environment variable", 1)); + let os_path = try!(os::getenv("PATH").to_cargo_error("Could not find the PATH environment variable".to_owned(), 1)); let path = os_path + PATH_SEP + self.path.connect(PATH_SEP); - let path = [(~"PATH", path)]; + let path = [("PATH".to_owned(), path)]; config.env = Some(path.as_slice()); println!("{:?}", config); - Process::configure(config).map(|mut ok| ok.wait_with_output()).to_cargo_error(~"Could not spawn process", 1) + Process::configure(config).map(|mut ok| ok.wait_with_output()).to_cargo_error("Could not spawn process".to_owned(), 1) } }