From: Yehuda Katz Date: Thu, 19 Jun 2014 17:43:46 +0000 (-0700) Subject: Rename to X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~998 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=af0f2733c754f4b2cd673472d47bcda659165137;p=cargo.git Rename to --- diff --git a/src/cargo/core/version_req.rs b/src/cargo/core/version_req.rs index 065f26bbe..0019a7fad 100644 --- a/src/cargo/core/version_req.rs +++ b/src/cargo/core/version_req.rs @@ -1,7 +1,7 @@ use std::fmt; use std::str::CharOffsets; use semver::Version; -use util::{CargoResult, error}; +use util::{CargoResult, internal}; #[deriving(PartialEq,Clone)] pub struct VersionReq { @@ -49,7 +49,7 @@ impl VersionReq { } if lexer.is_error() { - return Err(error("invalid version requirement")); + return Err(internal("invalid version requirement")); } predicates.push(try!(builder.build())); @@ -151,12 +151,12 @@ impl PredBuilder { fn set_sigil(&mut self, sigil: &str) -> CargoResult<()> { if self.op.is_some() { - return Err(error("op already set")); + return Err(internal("op already set")); } match Op::from_sigil(sigil) { Some(op) => self.op = Some(op), - _ => return Err(error("invalid sigil")) + _ => return Err(internal("invalid sigil")) } Ok(()) @@ -188,12 +188,12 @@ impl PredBuilder { fn build(&self) -> CargoResult { let op = match self.op { Some(x) => x, - None => return Err(error("op required")) + None => return Err(internal("op required")) }; let major = match self.major { Some(x) => x, - None => return Err(error("major version required")) + None => return Err(internal("major version required")) }; Ok(Predicate { @@ -384,7 +384,7 @@ fn parse_version_part(s: &str) -> CargoResult { let n = (c as uint) - ('0' as uint); if n > 9 { - return Err(error("version components must be numeric")); + return Err(internal("version components must be numeric")); } ret *= 10; diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 20544a0bf..d2370b39f 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -20,7 +20,7 @@ use core::{Source,SourceId,PackageSet,resolver}; use core::registry::PackageRegistry; use ops; use sources::{PathSource}; -use util::{CargoResult, Wrap, config, error, human}; +use util::{CargoResult, Wrap, config, internal, human}; pub fn compile(manifest_path: &Path) -> CargoResult<()> { log!(4, "compile; manifest-path={}", manifest_path.display()); @@ -56,7 +56,7 @@ fn source_ids_from_config() -> CargoResult> { let config_paths = configs.find_equiv(&"paths").map(|v| v.clone()).unwrap_or_else(|| ConfigValue::new()); let paths: Vec = match config_paths.get_value() { - &config::String(_) => return Err(error("The path was configured as a String instead of a List")), + &config::String(_) => return Err(internal("The path was configured as a String instead of a List")), &config::List(ref list) => list.iter().map(|path| Path::new(path.as_slice())).collect() }; diff --git a/src/cargo/ops/cargo_rustc.rs b/src/cargo/ops/cargo_rustc.rs index 59b7f42f0..0f6cee715 100644 --- a/src/cargo/ops/cargo_rustc.rs +++ b/src/cargo/ops/cargo_rustc.rs @@ -3,7 +3,7 @@ use std::io; use std::path::Path; use core::{Package,PackageSet,Target}; use util; -use util::{CargoResult, ProcessBuilder, error, human}; +use util::{CargoResult, ChainError, ProcessBuilder, internal, human}; type Args = Vec; @@ -45,8 +45,7 @@ fn compile_pkg(pkg: &Package, dest: &Path, deps_dir: &Path, primary: bool) -> Ca } fn mk_target(target: &Path) -> CargoResult<()> { - io::fs::mkdir_recursive(target, io::UserRWX) - .map_err(|_| error("could not create target directory")) + io::fs::mkdir_recursive(target, io::UserRWX).chain_error(|| internal("could not create target directory")) } fn rustc(root: &Path, target: &Target, dest: &Path, deps: &Path, verbose: bool) -> CargoResult<()> { @@ -98,6 +97,6 @@ fn build_deps_args(dst: &mut Args, deps: &Path) { fn topsort(deps: &PackageSet) -> CargoResult { match deps.sort() { Some(deps) => Ok(deps), - None => return Err(error("circular dependency detected")) + None => return Err(internal("circular dependency detected")) } } diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index d60a5fa06..b4e45bdc3 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -2,7 +2,7 @@ use std::fmt; use std::fmt::{Show,Formatter}; use core::{Package,PackageId,Summary,SourceId,Source}; use ops; -use util::{CargoResult, error}; +use util::{CargoResult, internal}; pub struct PathSource { id: SourceId, @@ -40,12 +40,12 @@ impl PathSource { log!(5, "get_root_package; source={}", self); if !self.updated { - return Err(error("source has not been updated")) + return Err(internal("source has not been updated")) } match self.packages.as_slice().head() { Some(pkg) => Ok(pkg.clone()), - None => Err(error("no package found in source")) + None => Err(internal("no package found in source")) } } } diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index 75609be15..e647dd6a6 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -2,7 +2,7 @@ use std::{io,fmt,os}; use std::collections::HashMap; use serialize::{Encodable,Encoder}; use toml; -use util::{CargoResult, ChainError, Require, error, internal_error, human}; +use util::{CargoResult, ChainError, Require, internal, human}; pub struct Config { home_path: Path @@ -95,8 +95,8 @@ impl fmt::Show for ConfigValue { } pub fn get_config(pwd: Path, key: &str) -> CargoResult { - find_in_tree(&pwd, |file| extract_config(file, key)) - .map_err(|_| internal_error("config key not found", format!("key={}", key))) + find_in_tree(&pwd, |file| extract_config(file, key)).map_err(|_| + internal(format!("config key not found; key={}", key))) } pub fn all_configs(pwd: Path) -> CargoResult> { @@ -115,7 +115,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 = cargo_try!(io::fs::File::open(&possible).chain_error(|| error("could not open file"))); + let file = cargo_try!(io::fs::File::open(&possible).chain_error(|| internal("could not open file"))); match walk(file) { Ok(res) => return Ok(res), _ => () @@ -125,7 +125,7 @@ fn find_in_tree(pwd: &Path, walk: |io::fs::File| -> CargoResult) -> CargoR if !current.pop() { break; } } - Err(error("")) + Err(internal("")) } fn walk_tree(pwd: &Path, walk: |io::fs::File| -> CargoResult<()>) -> CargoResult<()> { @@ -135,14 +135,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 = cargo_try!(io::fs::File::open(&possible).chain_error(|| error("could not open file"))); + let file = cargo_try!(io::fs::File::open(&possible).chain_error(|| internal("could not open file"))); match walk(file) { Err(_) => err = false, _ => () } } - if err { return Err(error("")); } + if err { return Err(internal("")); } if !current.pop() { break; } } @@ -153,12 +153,12 @@ fn extract_config(file: io::fs::File, key: &str) -> CargoResult { let path = file.path().clone(); let mut buf = io::BufferedReader::new(file); let root = cargo_try!(toml::parse_from_buffer(&mut buf)); - let val = cargo_try!(root.lookup(key).require(|| error(""))); + let val = cargo_try!(root.lookup(key).require(|| internal(""))); let v = match val { &toml::String(ref val) => String(val.clone()), &toml::Array(ref val) => List(val.iter().map(|s: &toml::Value| s.to_str()).collect()), - _ => return Err(error("")) + _ => return Err(internal("")) }; Ok(ConfigValue{ value: v, path: vec!(path) }) @@ -168,10 +168,10 @@ fn extract_all_configs(file: io::fs::File, map: &mut HashMap () } @@ -193,11 +193,11 @@ fn extract_all_configs(file: io::fs::File, map: &mut HashMap CargoResult<()> { match existing.value { - String(_) => return Err(error("should be an Array, but it was a String")), + String(_) => return Err(internal("should be an Array, but it was a String")), 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(error("should be an Array of Strings, but was an Array of other values")); + return Err(internal("should be an Array of Strings, but was an Array of other values")); } else { let new_list: Vec = new_list.move_iter().map(|v| v.unwrap()).collect(); list.push_all(new_list.as_slice()); @@ -211,6 +211,6 @@ fn merge_array(existing: &mut ConfigValue, val: &[toml::Value], path: &Path) -> fn toml_string(val: &toml::Value) -> CargoResult { match val { &toml::String(ref str) => Ok(str.clone()), - _ => Err(error("")) + _ => Err(internal("")) } } diff --git a/src/cargo/util/errors.rs b/src/cargo/util/errors.rs index adad8a8db..ff716fda3 100644 --- a/src/cargo/util/errors.rs +++ b/src/cargo/util/errors.rs @@ -236,7 +236,7 @@ pub fn internal_error(error: S1, detail: S2) -> Box } -pub fn error(error: S1) -> Box { +pub fn internal(error: S1) -> Box { box ConcreteCargoError { description: error.as_slice().to_str(), detail: None, diff --git a/src/cargo/util/mod.rs b/src/cargo/util/mod.rs index 1de113644..e88e9bfdc 100644 --- a/src/cargo/util/mod.rs +++ b/src/cargo/util/mod.rs @@ -2,7 +2,7 @@ pub use self::config::Config; pub use self::process_builder::{process,ProcessBuilder}; pub use self::result::{Wrap, Require}; pub use self::errors::{CargoResult, CargoError, BoxError, ChainError, CliResult, CliError, ProcessError}; -pub use self::errors::{process_error, internal_error, error, human, chain}; +pub use self::errors::{process_error, internal_error, internal, human, chain}; pub use self::paths::realpath; pub mod graph; diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 413ba1a7c..6312dc1a5 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -7,11 +7,11 @@ use serialize::Decodable; use core::{SourceId,GitKind}; use core::manifest::{LibKind,Lib}; use core::{Summary,Manifest,Target,Dependency,PackageId}; -use util::{CargoResult, Require, error, human}; +use util::{CargoResult, Require, human}; pub fn to_manifest(contents: &[u8], source_id: &SourceId) -> CargoResult<(Manifest, Vec)> { - let root = try!(toml::parse_from_bytes(contents).map_err(|_| error("Cargo.toml is not valid Toml"))); - let toml = try!(toml_to_manifest(root).map_err(|_| error("Cargo.toml is not a valid manifest"))); + let root = try!(toml::parse_from_bytes(contents).map_err(|_| human("Cargo.toml is not valid Toml"))); + let toml = try!(toml_to_manifest(root).map_err(|_| human("Cargo.toml is not a valid manifest"))); toml.to_manifest(source_id) }