]> git.proxmox.com Git - cargo.git/commitdiff
Squelch warnings and minor cleanup
authorYehuda Katz <wycats@gmail.com>
Thu, 19 Jun 2014 08:21:24 +0000 (01:21 -0700)
committerYehuda Katz <wycats@gmail.com>
Thu, 19 Jun 2014 08:21:24 +0000 (01:21 -0700)
13 files changed:
src/bin/cargo-read-manifest.rs
src/bin/cargo.rs
src/cargo/core/manifest.rs
src/cargo/lib.rs
src/cargo/ops/cargo_read_manifest.rs
src/cargo/ops/cargo_rustc.rs
src/cargo/sources/git/utils.rs
src/cargo/sources/path.rs
src/cargo/util/errors.rs
src/cargo/util/process_builder.rs
tests/support/mod.rs
tests/test_cargo_compile.rs
tests/test_cargo_compile_git_deps.rs

index 225c811d9c08a544d1d7161b2f2e32bd166f2b08..457af74eb138e2cabdaa183257ea4c1d20043f75 100644 (file)
@@ -25,7 +25,7 @@ fn execute(options: Options) -> CliResult<Option<Package>> {
     let source_id = SourceId::for_path(&Path::new(options.manifest_path.as_slice()));
     let mut source = PathSource::new(&source_id);
 
-    try!(source.update().map_err(|err| CLIError::new(err.get_desc(), Some(err.get_detail()), 1)));
+    try!(source.update().map_err(|err| CliError::new(err.description(), 1)));
 
     source
         .get_root_package()
index 2daaf3bef887442ed53886f0d23e520ff422033b..15c2762a69f57911938deb24b2f1fd75c53bd6b7 100644 (file)
@@ -13,7 +13,7 @@ use std::io::process::{Command,InheritFd,ExitStatus,ExitSignal};
 use serialize::Encodable;
 use cargo::{NoFlags,execute_main_without_stdin,handle_error};
 use cargo::util::important_paths::find_project;
-use cargo::util::{CliError, CliResult, CargoResult, CargoError, Require, config, box_error};
+use cargo::util::{CliError, CliResult, Require, config};
 
 fn main() {
     execute();
@@ -91,7 +91,7 @@ impl FlagConfig for ConfigForKeyFlags {
 }
 
 fn config_for_key(args: ConfigForKeyFlags) -> CliResult<Option<ConfigOut>> {
-    let value = try!(config::get_config(os::getcwd(), args.key.as_slice()).map_err(|err|
+    let value = try!(config::get_config(os::getcwd(), args.key.as_slice()).map_err(|_|
         CliError::new("Couldn't load configuration",  1)));
 
     if args.human {
@@ -116,7 +116,7 @@ impl FlagConfig for ConfigListFlags {
 }
 
 fn config_list(args: ConfigListFlags) -> CliResult<Option<ConfigOut>> {
-    let configs = try!(config::all_configs(os::getcwd()).map_err(|e|
+    let configs = try!(config::all_configs(os::getcwd()).map_err(|_|
         CliError::new("Couldn't load configuration", 1)));
 
     if args.human {
index da904e174d9aecf5568752967eded6475d37bb2b..a2cac38f72eb6f295b14869225836018757c8567 100644 (file)
@@ -10,7 +10,7 @@ use core::{
     Summary
 };
 use core::dependency::SerializedDependency;
-use util::{CargoResult, CargoError, box_error};
+use util::{CargoResult, box_error};
 
 #[deriving(PartialEq,Clone)]
 pub struct Manifest {
index c8dd26ef2c45ae087ea4a30c34de9c360448794f..b23b6ce336371eed6a542f2295d6a4c4b89575c2 100644 (file)
@@ -101,10 +101,10 @@ fn flags_from_args<T: RepresentsFlags>() -> CliResult<T> {
 
 fn json_from_stdin<T: RepresentsJSON>() -> CliResult<T> {
     let mut reader = io::stdin();
-    let input = try!(reader.read_to_str().map_err(|e| CliError::new("Standard in did not exist or was not UTF-8", 1)));
+    let input = try!(reader.read_to_str().map_err(|_| CliError::new("Standard in did not exist or was not UTF-8", 1)));
 
-    let json = try!(json::from_str(input.as_slice()).map_err(|e| CliError::new("Could not parse standard in as JSON", 1)));
+    let json = try!(json::from_str(input.as_slice()).map_err(|_| CliError::new("Could not parse standard in as JSON", 1)));
     let mut decoder = json::Decoder::new(json);
 
-    Decodable::decode(&mut decoder).map_err(|e: json::DecoderError| CliError::new("Could not process standard in as input", 1))
+    Decodable::decode(&mut decoder).map_err(|_| CliError::new("Could not process standard in as input", 1))
 }
index 809c38a2015de54fe8338cdfb4a3f8bc8941d531..f5524618e37895a40fbc09ef93866d5d10ef7030 100644 (file)
@@ -1,7 +1,7 @@
 use std::io::File;
 use util;
 use core::{Package,Manifest,SourceId};
-use util::{CargoResult, CargoError, box_error, human};
+use util::{CargoResult, box_error, human};
 
 pub fn read_manifest(contents: &[u8], source_id: &SourceId) -> CargoResult<(Manifest, Vec<Path>)> {
     util::toml::to_manifest(contents, source_id).map_err(human)
index 90cb85f8a5dfb196735409d7bbc7f2b3f59d1d48..eb5fc6d683d4a85b752af3b19a84328899dabe69 100644 (file)
@@ -1,10 +1,9 @@
 use std::os::args;
 use std::io;
 use std::path::Path;
-use std::str;
 use core::{Package,PackageSet,Target};
 use util;
-use util::{CargoResult, CargoError, ProcessBuilder, error, human, box_error};
+use util::{CargoResult, CargoError, ProcessBuilder, error, human};
 
 type Args = Vec<String>;
 
@@ -60,7 +59,7 @@ fn rustc(root: &Path, target: &Target, dest: &Path, deps: &Path, verbose: bool)
 
         let rustc = prepare_rustc(root, target, *crate_type, dest, deps);
 
-        try!((if verbose {
+        try!(if verbose {
             rustc.exec().map_err(|err| {
                 log!(5, "exec failed; error={}", err.description());
                 human(err)
@@ -70,7 +69,7 @@ fn rustc(root: &Path, target: &Target, dest: &Path, deps: &Path, verbose: bool)
                 log!(5, "exec_with_output failed; error={}", err.description());
                 human(err)
             })
-        }));
+        });
     }
 
     Ok(())
index f8f9f59549fadc90de8beef9e811e0ffc71bc612..c1fbc4edfc4e85acf8794074853e72a9b15163bd 100644 (file)
@@ -226,11 +226,11 @@ impl GitCheckout {
     fn clone_repo(&self) -> CargoResult<()> {
         let dirname = Path::new(self.location.dirname());
 
-        try!(mkdir_recursive(&dirname, UserDir).map_err(|e|
+        try!(mkdir_recursive(&dirname, UserDir).map_err(|_|
             box_error(format!("Couldn't mkdir {}", Path::new(self.location.dirname()).display()))));
 
         if self.location.exists() {
-            try!(rmdir_recursive(&self.location).map_err(|e|
+            try!(rmdir_recursive(&self.location).map_err(|_|
                 box_error(format!("Couldn't rmdir {}", Path::new(&self.location).display()))));
         }
 
@@ -267,7 +267,7 @@ fn git_inherit(path: &Path, str: String) -> CargoResult<()> {
 }
 
 fn git_output(path: &Path, str: String) -> CargoResult<String> {
-    let output = try!(git(path, str.as_slice()).exec_with_output().map_err(|err|
+    let output = try!(git(path, str.as_slice()).exec_with_output().map_err(|_|
         box_error(format!("Executing `git {}` failed", str))));
 
     Ok(to_str(output.output.as_slice()).as_slice().trim_right().to_str())
index 918027469e0c320f5066ec868648dd27c39c242f..7aa292f188b00f452de796ca5b6f17c97e7de8a2 100644 (file)
@@ -40,7 +40,7 @@ impl PathSource {
         log!(5, "get_root_package; source={}", self);
 
         if !self.updated {
-            return Err(simple_human("source has not been updated"))
+            return Err(box_error("source has not been updated"))
         }
 
         match self.packages.as_slice().head() {
index 833cd014a8fd56d97795b83b08be9a85e4c2fab1..8c9187d4f53b275da6c93bb6ecf2087f34de045e 100644 (file)
@@ -21,6 +21,7 @@ pub trait CargoError {
     }
 }
 
+
 impl Show for Box<CargoError> {
     fn fmt(&self, f: &mut Formatter) -> fmt::Result {
         try!(write!(f, "{}", self.description()));
@@ -67,6 +68,7 @@ impl CargoError for TomlError {
 }
 
 pub struct ProcessError {
+    pub msg: String,
     pub command: String,
     pub exit: Option<ProcessExit>,
     pub output: Option<ProcessOutput>,
@@ -90,7 +92,7 @@ impl CargoError for ProcessError {
             Some(ExitStatus(i)) | Some(ExitSignal(i)) => i.to_str(),
             None => "never executed".to_str()
         };
-        format!("Executing `{}` failed (status={})", self.command, exit)
+        format!("{} (status={})", self.msg, exit)
     }
 
     fn detail(&self) -> Option<String> {
@@ -102,7 +104,7 @@ impl CargoError for ProcessError {
     }
 }
 
-struct ConcreteCargoError {
+pub struct ConcreteCargoError {
     description: String,
     detail: Option<String>,
     cause: Option<Box<CargoError>>,
@@ -160,6 +162,7 @@ impl CliError {
 
 pub fn process_error<S: Str>(msg: S, command: &Command, status: Option<&ProcessExit>, output: Option<&ProcessOutput>) -> ProcessError {
     ProcessError {
+        msg: msg.as_slice().to_str(),
         command: command.to_str(),
         exit: status.map(|o| o.clone()),
         output: output.map(|o| o.clone()),
index 6adede8eb222067105de7651632f52708d4e18e4..251cc97737dd6d5bc68cd2a51a162951111236e6 100644 (file)
@@ -3,7 +3,7 @@ use std::fmt::{Show,Formatter};
 use std::os;
 use std::path::Path;
 use std::io::process::{Command,ProcessOutput,InheritFd};
-use util::{CargoResult, CargoError, ProcessError, process_error, box_error};
+use util::{ProcessError, process_error};
 use std::collections::HashMap;
 
 #[deriving(Clone,PartialEq)]
@@ -74,7 +74,7 @@ impl ProcessBuilder {
 
         let msg = || format!("Could not execute process `{}`", self.debug_string());
 
-        let exit = try!(command.status().map_err(|e| process_error(msg(), &command, None, None)));
+        let exit = try!(command.status().map_err(|_| process_error(msg(), &command, None, None)));
 
         if exit.success() {
             Ok(())
@@ -89,7 +89,7 @@ impl ProcessBuilder {
 
         let msg = || format!("Could not execute process `{}`", self.debug_string());
 
-        let output = try!(command.output().map_err(|e| process_error(msg(), &command, None, None)));
+        let output = try!(command.output().map_err(|_| process_error(msg(), &command, None, None)));
 
         if output.status.success() {
             Ok(output)
index 552852a3d8f38a0aefcce1f9cbaf7e74e170fade..621b4481f9093cdcc4829039e73f223df8413005 100644 (file)
@@ -10,7 +10,7 @@ use std::vec::Vec;
 use std::fmt::Show;
 use ham = hamcrest;
 use cargo::core::shell;
-use cargo::util::{process,ProcessBuilder,CargoError};
+use cargo::util::{process,ProcessBuilder};
 use cargo::util::ProcessError;
 
 pub mod paths;
index 52635b4d3235567d2d677b7389b9be5ea202c064..e096df9b221ddd04fbfe4ee1639e33d46e082861 100644 (file)
@@ -64,7 +64,7 @@ test!(cargo_compile_with_invalid_code {
     assert_that(p.cargo_process("cargo-compile"),
         execs()
         .with_status(101)
-        .with_stderr(format!("src/foo.rs:1:1: 1:8 error: expected item but found `invalid`\nsrc/foo.rs:1 invalid rust code!\n             ^~~~~~~\nExecuting `rustc 'src/foo.rs' '--crate-type' 'bin' '--out-dir' '{}' '-L' '{}'` failed (status=101)", target.display(), target.join("deps").display()).as_slice()));
+        .with_stderr(format!("src/foo.rs:1:1: 1:8 error: expected item but found `invalid`\nsrc/foo.rs:1 invalid rust code!\n             ^~~~~~~\nCould not execute process `rustc src/foo.rs --crate-type bin --out-dir {} -L {}` (status=101)", target.display(), target.join("deps").display()).as_slice()));
 })
 
 test!(cargo_compile_with_warnings_in_the_root_package {
index 117b7edc787419761a13d065aa48a17d30036a0e..2e57b76b92cbbef2b66219191173f6f5e9ece613 100644 (file)
@@ -3,7 +3,7 @@ use std::io::File;
 use support::{ProjectBuilder, ResultTest, project, execs, main_file, paths};
 use hamcrest::{assert_that,existing_file};
 use cargo;
-use cargo::util::{CargoResult, ProcessError, process};
+use cargo::util::{ProcessError, process};
 
 fn setup() {
 }