From 8b1cdbf6957fc2ceb8f70229312f40fb53828020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Tue, 7 Aug 2018 23:00:46 +0200 Subject: [PATCH 1/4] Replace deprecated std::env::home_dir --- Cargo.toml | 1 + src/lib.rs | 1 + src/options.rs | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index b6ae4360c6..2eea7daa1c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,6 +40,7 @@ clap = "2.30" json = "0.11" toml = "0.4" url = "1.7" +dirs = "1.0.2" [dependencies.semver] version = "0.9" diff --git a/src/lib.rs b/src/lib.rs index b6fcc5c0a2..04f45ff303 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -316,6 +316,7 @@ extern crate clap; extern crate toml; extern crate json; extern crate url; +extern crate dirs; mod options; diff --git a/src/options.rs b/src/options.rs index 60854e9828..da1cfe89b3 100644 --- a/src/options.rs +++ b/src/options.rs @@ -15,11 +15,12 @@ use self::super::ops::{PackageFilterElement, ConfigOperation}; use semver::{VersionReq as SemverReq, Version as Semver}; use clap::{self, AppSettings, SubCommand, App, Arg}; -use std::env::{self, home_dir}; +use std::env; use array_tool::vec::Uniq; use std::path::PathBuf; use std::str::FromStr; use std::fs; +use dirs::home_dir; /// Representation of the application's all configurable values. From d286422487c9277b5df4a5e374f08c8bfedf58f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Tue, 7 Aug 2018 23:01:22 +0200 Subject: [PATCH 2/4] Bump dependencies New regex enables SIMD on supported plaftorms. --- Cargo.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2eea7daa1c..f9bbb7fd09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,14 +29,14 @@ exclude = ["*.enc"] [dependencies] serde_derive = "1.0" -lazy_static = "1.0" +lazy_static = "1.1.0" array_tool = "1.0" -tabwriter = "1.0" +tabwriter = "1.1" lazysort = "0.2" -regex = "0.2" +regex = "1.0.2" serde = "1.0" -git2 = "0.6" -clap = "2.30" +git2 = "0.7.5" +clap = "2.32" json = "0.11" toml = "0.4" url = "1.7" From 766527c79c752cdf9910027894865f6f4fa1aa1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Tue, 7 Aug 2018 23:23:20 +0200 Subject: [PATCH 3/4] Clippy knows better how to do it --- src/lib.rs | 1 + src/main.rs | 14 +++++++------- src/options.rs | 10 +++++----- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 04f45ff303..1c27488f08 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -302,6 +302,7 @@ //! Updated 1 package. //! ``` +#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))] #[macro_use] extern crate serde_derive; diff --git a/src/main.rs b/src/main.rs index 8fd35b8215..71320d7a81 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,7 +59,7 @@ fn actual_main() -> Result<(), i32> { if !search_res.success() { return Err(search_res.code().unwrap_or(-1)); } - println!(""); + println!(); } let registry = cargo_update::ops::get_index_path(&opts.cargo_dir.1); @@ -103,7 +103,7 @@ fn actual_main() -> Result<(), i32> { }) .unwrap(); } - writeln!(out, "").unwrap(); + writeln!(out).unwrap(); out.flush().unwrap(); } @@ -151,7 +151,7 @@ fn actual_main() -> Result<(), i32> { } .unwrap(); - println!(""); + println!(); if !install_res.success() { if cfg!(target_os = "windows") && package.version.is_some() && package.name == "cargo-update" { restore_cargo_update_exec(package.version.as_ref().unwrap()); @@ -170,7 +170,7 @@ fn actual_main() -> Result<(), i32> { } }); - println!(""); + println!(); println!("Updated {} package{}.", success_n, if success_n == 1 { "" } else { "s" }); if !errored.is_empty() && result.is_some() { println!("Failed to update {}.", &errored.iter().fold("".to_string(), |s, e| s + ", " + e)[2..]); @@ -208,7 +208,7 @@ fn actual_main() -> Result<(), i32> { if package.needs_update() { "Yes" } else { "No" }) .unwrap(); } - writeln!(out, "").unwrap(); + writeln!(out).unwrap(); out.flush().unwrap(); } @@ -250,7 +250,7 @@ fn actual_main() -> Result<(), i32> { } .unwrap(); - println!(""); + println!(); if !install_res.success() { if cfg!(target_os = "windows") && package.name == "cargo-update" { restore_cargo_update_exec(&package.id.to_string()); @@ -269,7 +269,7 @@ fn actual_main() -> Result<(), i32> { } }); - println!(""); + println!(); println!("Updated {} git package{}.", success_n, if success_n == 1 { "" } else { "s" }); if !errored.is_empty() && result.is_some() { println!("Failed to update {}.", &errored.iter().fold("".to_string(), |s, e| s + ", " + e)[2..]); diff --git a/src/options.rs b/src/options.rs index da1cfe89b3..5eefa4dd88 100644 --- a/src/options.rs +++ b/src/options.rs @@ -74,9 +74,9 @@ impl Options { .about("A cargo subcommand for checking and applying updates to installed executables") .args(&[Arg::from_usage("-c --cargo-dir=[CARGO_DIR] 'The cargo home directory. Default: $CARGO_HOME or $HOME/.cargo'") .visible_alias("root") - .validator(|s| existing_dir_validator("Cargo", s)), + .validator(|s| existing_dir_validator("Cargo", &s)), Arg::from_usage("-t --temp-dir=[TEMP_DIR] 'The temporary directory. Default: $TEMP/cargo-update'") - .validator(|s| existing_dir_validator("Temporary", s)), + .validator(|s| existing_dir_validator("Temporary", &s)), Arg::from_usage("-a --all 'Update all packages'").conflicts_with("PACKAGE"), Arg::from_usage("-l --list 'Don't update packages, only list and check if they need an update'"), Arg::from_usage("-f --force 'Update all packages regardless if they need updating'"), @@ -146,7 +146,7 @@ impl ConfigOptions { .author(crate_authors!("\n")) .about("A cargo subcommand for checking and applying updates to installed executables -- configuration") .args(&[Arg::from_usage("-c --cargo-dir=[CARGO_DIR] 'The cargo home directory. Default: $CARGO_HOME or $HOME/.cargo'") - .validator(|s| existing_dir_validator("Cargo", s)), + .validator(|s| existing_dir_validator("Cargo", &s)), Arg::from_usage("-t --toolchain=[TOOLCHAIN] 'Toolchain to use or empty for default'"), Arg::from_usage("-f --feature=[FEATURE]... 'Feature to enable'"), Arg::from_usage("-n --no-feature=[DISABLED_FEATURE]... 'Feature to disable'"), @@ -225,8 +225,8 @@ fn cargo_dir() -> (String, PathBuf) { } } -fn existing_dir_validator(label: &str, s: String) -> Result<(), String> { - fs::canonicalize(&s).map(|_| ()).map_err(|_| format!("{} directory \"{}\" not found", label, s)) +fn existing_dir_validator(label: &str, s: &str) -> Result<(), String> { + fs::canonicalize(s).map(|_| ()).map_err(|_| format!("{} directory \"{}\" not found", label, s)) } fn package_parse(s: String) -> Result<(String, Option), String> { From 9109bdf7083464685c04fefd0f2ad1a642bce04a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Mon, 13 Aug 2018 21:58:04 +0200 Subject: [PATCH 4/4] Do not reorder imports --- rustfmt.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/rustfmt.toml b/rustfmt.toml index ad979d6428..df2f0de0ed 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -5,3 +5,4 @@ fn_args_paren_newline = false fn_args_density = "Compressed" struct_trailing_comma = "Always" wrap_comments = true +reorder_imports = false