From b666a1deca6f455ec32f3a693bdf8591a0c178ed Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sat, 13 Apr 2019 16:40:02 +0700 Subject: [PATCH 1/8] Remove unused dep: ole32-sys --- Cargo.lock | 11 ----------- Cargo.toml | 1 - 2 files changed, 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0fa16b018c..28deb6ba55 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -855,15 +855,6 @@ dependencies = [ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ole32-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "opaque-debug" version = "0.2.2" @@ -1261,7 +1252,6 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "markdown 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.10.20 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2004,7 +1994,6 @@ dependencies = [ "checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea" "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" "checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba" -"checksum ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c" "checksum opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "93f5bb2e8e8dec81642920ccff6b61f1eb94fa3020c5a325c9851ff604152409" "checksum openssl 0.10.20 (registry+https://github.com/rust-lang/crates.io-index)" = "5a0d6b781aac4ac1bd6cafe2a2f0ad8c16ae8e1dd5184822a16c50139f8838d9" "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" diff --git a/Cargo.toml b/Cargo.toml index c2d925f338..631a32ba1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,6 @@ flate2 = "1" itertools = "0.8" libc = "0.2" markdown = "0.2" -ole32-sys = "0.2" rand = "0.6" regex = "1" remove_dir_all = "0.5.1" From 979791ff5a0686fa310521ecff9b5c3b80d39499 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sat, 13 Apr 2019 16:43:21 +0700 Subject: [PATCH 2/8] Remove unused dep: itertools --- Cargo.lock | 16 ---------------- Cargo.toml | 1 - src/errors.rs | 15 ++++++++++----- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28deb6ba55..22809b95ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -370,11 +370,6 @@ name = "dtoa" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "either" -version = "1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "encoding_rs" version = "0.8.17" @@ -619,14 +614,6 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "itertools" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "itoa" version = "0.4.3" @@ -1248,7 +1235,6 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "git-testament 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "markdown 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1938,7 +1924,6 @@ dependencies = [ "checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c" "checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" "checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd" -"checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b" "checksum encoding_rs 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)" = "4155785c79f2f6701f185eb2e6b4caf0555ec03477cb4c70db67b465311620ed" "checksum env_proxy 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d1be90999077d0d3fc3d4c96aa098cfc3b414ee25bff87423afa055c4a115af8" "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" @@ -1966,7 +1951,6 @@ dependencies = [ "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" -"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" diff --git a/Cargo.toml b/Cargo.toml index 631a32ba1e..553d7114c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,6 @@ download = { path = "download" } clap = "2" error-chain = "0.12" flate2 = "1" -itertools = "0.8" libc = "0.2" markdown = "0.2" rand = "0.6" diff --git a/src/errors.rs b/src/errors.rs index b5014dfb9b..1155b1fc97 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -337,17 +337,22 @@ fn component_unavailable_msg(cs: &[Component], manifest: &Manifest) -> String { &cs[0].description(manifest) ); } else { - use itertools::Itertools; let same_target = cs .iter() .all(|c| c.target == cs[0].target || c.target.is_none()); if same_target { - let mut cs_strs = cs.iter().map(|c| format!("'{}'", c.short_name(manifest))); - let cs_str = cs_strs.join(", "); + let cs_str = cs + .iter() + .map(|c| format!("'{}'", c.short_name(manifest))) + .collect::>() + .join(", "); let _ = write!(buf, "some components unavailable for download: {}", cs_str,); } else { - let mut cs_strs = cs.iter().map(|c| c.description(manifest)); - let cs_str = cs_strs.join(", "); + let cs_str = cs + .iter() + .map(|c| c.description(manifest)) + .collect::>() + .join(", "); let _ = write!(buf, "some components unavailable for download: {}", cs_str,); } } From 3eb284952dcc0b5f31d43f3b6d703a6cd233ebc8 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sat, 13 Apr 2019 17:13:59 +0700 Subject: [PATCH 3/8] Remove redundant `'static` lifetime annotation --- src/cli/help.rs | 32 ++++++++++++++++---------------- src/cli/self_update.rs | 6 +++--- src/dist/dist.rs | 30 +++++++++++++++--------------- src/lib.rs | 4 ++-- tests/dist_manifest.rs | 4 ++-- tests/mock/clitools.rs | 6 +++--- 6 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/cli/help.rs b/src/cli/help.rs index f2a71b5189..8893a8cb2e 100644 --- a/src/cli/help.rs +++ b/src/cli/help.rs @@ -1,4 +1,4 @@ -pub static RUSTUP_HELP: &'static str = r"DISCUSSION: +pub static RUSTUP_HELP: &str = r"DISCUSSION: rustup installs The Rust Programming Language from the official release channels, enabling you to easily switch between stable, beta, and nightly compilers and keep them updated. It makes @@ -8,7 +8,7 @@ pub static RUSTUP_HELP: &'static str = r"DISCUSSION: If you are new to Rust consider running `rustup doc --book` to learn Rust."; -pub static SHOW_HELP: &'static str = r"DISCUSSION: +pub static SHOW_HELP: &str = r"DISCUSSION: Shows the name of the active toolchain and the version of `rustc`. If the active toolchain has installed support for additional @@ -17,7 +17,7 @@ pub static SHOW_HELP: &'static str = r"DISCUSSION: If there are multiple toolchains installed then all installed toolchains are listed as well."; -pub static SHOW_ACTIVE_TOOLCHAIN_HELP: &'static str = r"DISCUSSION: +pub static SHOW_ACTIVE_TOOLCHAIN_HELP: &str = r"DISCUSSION: Shows the name of the active toolchain. This is useful for figuring out the active tool chain from @@ -26,7 +26,7 @@ pub static SHOW_ACTIVE_TOOLCHAIN_HELP: &'static str = r"DISCUSSION: You should use `rustc --print sysroot` to get the sysroot, or `rustc --version` to get the toolchain version."; -pub static UPDATE_HELP: &'static str = r"DISCUSSION: +pub static UPDATE_HELP: &str = r"DISCUSSION: With no toolchain specified, the `update` command updates each of the installed toolchains from the official release channels, then updates rustup itself. @@ -34,16 +34,16 @@ pub static UPDATE_HELP: &'static str = r"DISCUSSION: If given a toolchain argument then `update` updates that toolchain, the same as `rustup toolchain install`."; -pub static INSTALL_HELP: &'static str = r"DISCUSSION: +pub static INSTALL_HELP: &str = r"DISCUSSION: Installs a specific rust toolchain. The 'install' command is an alias for 'rustup update '."; -pub static DEFAULT_HELP: &'static str = r"DISCUSSION: +pub static DEFAULT_HELP: &str = r"DISCUSSION: Sets the default toolchain to the one specified. If the toolchain is not already installed then it is installed first."; -pub static TOOLCHAIN_HELP: &'static str = r"DISCUSSION: +pub static TOOLCHAIN_HELP: &str = r"DISCUSSION: Many `rustup` commands deal with *toolchains*, a single installation of the Rust compiler. `rustup` supports multiple types of toolchains. The most basic track the official release @@ -80,7 +80,7 @@ pub static TOOLCHAIN_HELP: &'static str = r"DISCUSSION: often used to for developing Rust itself. For more information see `rustup toolchain help link`."; -pub static TOOLCHAIN_LINK_HELP: &'static str = r"DISCUSSION: +pub static TOOLCHAIN_LINK_HELP: &str = r"DISCUSSION: 'toolchain' is the custom name to be assigned to the new toolchain. Any name is permitted as long as it does not fully match an initial substring of a standard release channel. For example, you can use @@ -99,7 +99,7 @@ pub static TOOLCHAIN_LINK_HELP: &'static str = r"DISCUSSION: If you now compile a crate in the current directory, the custom toolchain 'latest-stage1' will be used."; -pub static OVERRIDE_HELP: &'static str = r"DISCUSSION: +pub static OVERRIDE_HELP: &str = r"DISCUSSION: Overrides configure rustup to use a specific toolchain when running in a specific directory. @@ -120,14 +120,14 @@ pub static OVERRIDE_HELP: &'static str = r"DISCUSSION: override and use the default toolchain again, `rustup override unset`."; -pub static OVERRIDE_UNSET_HELP: &'static str = r"DISCUSSION: +pub static OVERRIDE_UNSET_HELP: &str = r"DISCUSSION: If `--path` argument is present, removes the override toolchain for the specified directory. If `--nonexistent` argument is present, removes the override toolchain for all nonexistent directories. Otherwise, removes the override toolchain for the current directory."; -pub static RUN_HELP: &'static str = r"DISCUSSION: +pub static RUN_HELP: &str = r"DISCUSSION: Configures an environment to use the given toolchain and then runs the specified program. The command may be any program, not just rustc or cargo. This can be used for testing arbitrary toolchains @@ -142,14 +142,14 @@ pub static RUN_HELP: &'static str = r"DISCUSSION: $ rustup run nightly cargo build"; -pub static DOC_HELP: &'static str = r"DISCUSSION: +pub static DOC_HELP: &str = r"DISCUSSION: Opens the documentation for the currently active toolchain with the default browser. By default, it opens the documentation index. Use the various flags to open specific pieces of documentation."; -pub static COMPLETIONS_HELP: &'static str = +pub static COMPLETIONS_HELP: &str = r"DISCUSSION: One can generate a completion script for `rustup` that is compatible with a given shell. The script is output on `stdout` @@ -268,6 +268,6 @@ r"DISCUSSION: $ rustup completions zsh cargo > ~/.zfunc/_cargo"; -pub static TOOLCHAIN_ARG_HELP: &'static str = "Toolchain name, such as 'stable', 'nightly', \ - or '1.8.0'. For more information see `rustup \ - help toolchain`"; +pub static TOOLCHAIN_ARG_HELP: &str = "Toolchain name, such as 'stable', 'nightly', \ + or '1.8.0'. For more information see `rustup \ + help toolchain`"; diff --git a/src/cli/self_update.rs b/src/cli/self_update.rs index cf1cd9c7fa..595ef42f90 100644 --- a/src/cli/self_update.rs +++ b/src/cli/self_update.rs @@ -170,7 +170,7 @@ This will uninstall all Rust toolchains and data, and remove }; } -static MSVC_MESSAGE: &'static str = r#"# Rust Visual C++ prerequisites +static MSVC_MESSAGE: &str = r#"# Rust Visual C++ prerequisites Rust requires the Microsoft C++ build tools for Visual Studio 2013 or later, but they don't seem to be installed. @@ -196,7 +196,7 @@ doing then it is fine to continue installation without the build tools, but otherwise, install the C++ build tools before proceeding. "#; -static UPDATE_ROOT: &'static str = "https://static.rust-lang.org/rustup"; +static UPDATE_ROOT: &str = "https://static.rust-lang.org/rustup"; /// `CARGO_HOME` suitable for display, possibly with $HOME /// substituted for the directory prefix @@ -219,7 +219,7 @@ fn canonical_cargo_home() -> Result { } /// Installing is a simple matter of coping the running binary to -/// `CARGO_HOME`/bin, hardlinking the various Rust tools to it, +/// `CARGO_HOME`/bin, hard-linking the various Rust tools to it, /// and adding `CARGO_HOME`/bin to PATH. pub fn install(no_prompt: bool, verbose: bool, mut opts: InstallOpts) -> Result<()> { do_pre_install_sanity_checks()?; diff --git a/src/dist/dist.rs b/src/dist/dist.rs index e011961992..6e7843cc1e 100644 --- a/src/dist/dist.rs +++ b/src/dist/dist.rs @@ -8,16 +8,16 @@ use crate::dist::temp; use crate::errors::*; use crate::utils::utils; +use regex::Regex; + use std::env; use std::fmt; use std::path::Path; -use regex::Regex; - -pub const DEFAULT_DIST_SERVER: &str = "https://static.rust-lang.org"; +pub static DEFAULT_DIST_SERVER: &str = "https://static.rust-lang.org"; // Deprecated -pub const DEFAULT_DIST_ROOT: &str = "https://static.rust-lang.org/dist"; +pub static DEFAULT_DIST_ROOT: &str = "https://static.rust-lang.org/dist"; // A toolchain descriptor from rustup's perspective. These contain // 'partial target triples', which allow toolchain names like @@ -56,7 +56,7 @@ pub struct TargetTriple(String); // These lists contain the targets known to rustup, and used to build // the PartialTargetTriple. -static LIST_ARCHS: &'static [&'static str] = &[ +static LIST_ARCHS: &[&str] = &[ "i386", "i586", "i686", @@ -74,7 +74,7 @@ static LIST_ARCHS: &'static [&'static str] = &[ "powerpc64le", "s390x", ]; -static LIST_OSES: &'static [&'static str] = &[ +static LIST_OSES: &[&str] = &[ "pc-windows", "unknown-linux", "apple-darwin", @@ -84,7 +84,7 @@ static LIST_OSES: &'static [&'static str] = &[ "rumprun-netbsd", "unknown-freebsd", ]; -static LIST_ENVS: &'static [&'static str] = &[ +static LIST_ENVS: &[&str] = &[ "gnu", "msvc", "gnueabi", @@ -100,14 +100,14 @@ static LIST_ENVS: &'static [&'static str] = &[ // Hence we could distinguish between the variants with compile-time cfg() // attributes alone. #[cfg(all(not(windows), target_endian = "big"))] -const TRIPLE_MIPS_UNKNOWN_LINUX_GNU: &str = "mips-unknown-linux-gnu"; +static TRIPLE_MIPS_UNKNOWN_LINUX_GNU: &str = "mips-unknown-linux-gnu"; #[cfg(all(not(windows), target_endian = "little"))] -const TRIPLE_MIPS_UNKNOWN_LINUX_GNU: &str = "mipsel-unknown-linux-gnu"; +static TRIPLE_MIPS_UNKNOWN_LINUX_GNU: &str = "mipsel-unknown-linux-gnu"; #[cfg(all(not(windows), target_endian = "big"))] -const TRIPLE_MIPS64_UNKNOWN_LINUX_GNUABI64: &str = "mips64-unknown-linux-gnuabi64"; +static TRIPLE_MIPS64_UNKNOWN_LINUX_GNUABI64: &str = "mips64-unknown-linux-gnuabi64"; #[cfg(all(not(windows), target_endian = "little"))] -const TRIPLE_MIPS64_UNKNOWN_LINUX_GNUABI64: &str = "mips64el-unknown-linux-gnuabi64"; +static TRIPLE_MIPS64_UNKNOWN_LINUX_GNUABI64: &str = "mips64el-unknown-linux-gnuabi64"; impl TargetTriple { pub fn from_str(name: &str) -> Self { @@ -251,7 +251,7 @@ impl PartialTargetTriple { impl PartialToolchainDesc { pub fn from_str(name: &str) -> Result { - let channels = [ + static CHANNELS: &[&str] = &[ "nightly", "beta", "stable", @@ -261,7 +261,7 @@ impl PartialToolchainDesc { let pattern = format!( r"^({})(?:-(\d{{4}}-\d{{2}}-\d{{2}}))?(?:-(.*))?$", - channels.join("|") + CHANNELS.join("|") ); let re = Regex::new(&pattern).unwrap(); @@ -341,7 +341,7 @@ impl PartialToolchainDesc { impl ToolchainDesc { pub fn from_str(name: &str) -> Result { - let channels = [ + static CHANNELS: &[&str] = &[ "nightly", "beta", "stable", @@ -351,7 +351,7 @@ impl ToolchainDesc { let pattern = format!( r"^({})(?:-(\d{{4}}-\d{{2}}-\d{{2}}))?-(.*)?$", - channels.join("|"), + CHANNELS.join("|"), ); let re = Regex::new(&pattern).unwrap(); diff --git a/src/lib.rs b/src/lib.rs index 95960981d3..a48f3497e3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,7 @@ pub use crate::toolchain::*; pub use crate::utils::{notify, toml_utils}; // A list of all binaries which Rustup will proxy. -pub static TOOLS: &'static [&'static str] = &[ +pub static TOOLS: &[&str] = &[ "rustc", "rustdoc", "cargo", @@ -22,7 +22,7 @@ pub static TOOLS: &'static [&'static str] = &[ // Tools which are commonly installed by Cargo as well as rustup. We take a bit // more care with these to ensure we don't overwrite the user's previous // installation. -pub static DUP_TOOLS: &'static [&'static str] = &["rustfmt", "cargo-fmt"]; +pub static DUP_TOOLS: &[&str] = &["rustfmt", "cargo-fmt"]; fn component_for_bin(binary: &str) -> Option<&'static str> { use std::env::consts::EXE_SUFFIX; diff --git a/tests/dist_manifest.rs b/tests/dist_manifest.rs index 1f382dc3f8..d0b81c921e 100644 --- a/tests/dist_manifest.rs +++ b/tests/dist_manifest.rs @@ -3,9 +3,9 @@ use rustup::dist::manifest::Manifest; use rustup::ErrorKind; // Example manifest from https://public.etherpad-mozilla.org/p/Rust-infra-work-week -static EXAMPLE: &'static str = include_str!("channel-rust-nightly-example.toml"); +static EXAMPLE: &str = include_str!("channel-rust-nightly-example.toml"); // From brson's live build-rust-manifest.py script -static EXAMPLE2: &'static str = include_str!("channel-rust-nightly-example2.toml"); +static EXAMPLE2: &str = include_str!("channel-rust-nightly-example2.toml"); #[test] fn parse_smoke_test() { diff --git a/tests/mock/clitools.rs b/tests/mock/clitools.rs index 29a28b9084..a4044084a2 100644 --- a/tests/mock/clitools.rs +++ b/tests/mock/clitools.rs @@ -54,14 +54,14 @@ pub enum Scenario { Unavailable, // Two dates, v2 manifests, everything unavailable in second date. } -pub static CROSS_ARCH1: &'static str = "x86_64-unknown-linux-musl"; -pub static CROSS_ARCH2: &'static str = "arm-linux-androideabi"; +pub static CROSS_ARCH1: &str = "x86_64-unknown-linux-musl"; +pub static CROSS_ARCH2: &str = "arm-linux-androideabi"; // Architecture for testing 'multi-host' installation. // FIXME: Unfortunately the list of supported hosts is hard-coded, // so we have to use the triple of a host we actually test on. That means // that when we're testing on that host we can't test 'multi-host'. -pub static MULTI_ARCH1: &'static str = "i686-unknown-linux-gnu"; +pub static MULTI_ARCH1: &str = "i686-unknown-linux-gnu"; /// Run this to create the test environment containing rustup, and /// a mock dist server. From b0591270cf985143462223a973f4ef3e3e5ac586 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sat, 13 Apr 2019 17:15:06 +0700 Subject: [PATCH 4/8] Remove global allocator System allocator has been used by default since Rust v.1.32. --- src/cli/main.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/cli/main.rs b/src/cli/main.rs index 7aa311c6b8..1315a12ac5 100644 --- a/src/cli/main.rs +++ b/src/cli/main.rs @@ -30,14 +30,9 @@ mod term2; use crate::errors::*; use rustup::env_var::RUST_RECURSION_COUNT_MAX; -use std::alloc::System; use std::env; use std::path::PathBuf; -// Always use the system allocator, to reduce binary size. -#[global_allocator] -static _ALLOCATOR: System = System; - fn main() { if let Err(ref e) = run_rustup() { common::report_error(e); From d88d73674a5235621d4dcde4b7fd955203bca518 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sat, 13 Apr 2019 18:13:51 +0700 Subject: [PATCH 5/8] Make truly random string --- src/utils/raw.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/utils/raw.rs b/src/utils/raw.rs index e86f53cc3e..d433e09e8d 100644 --- a/src/utils/raw.rs +++ b/src/utils/raw.rs @@ -1,4 +1,3 @@ -use std::char::from_u32; use std::env; use std::error; use std::ffi::{OsStr, OsString}; @@ -10,8 +9,6 @@ use std::path::Path; use std::process::{Command, ExitStatus}; use std::str; -use rand::random; - pub fn ensure_dir_exists, F: FnOnce(&Path)>( path: P, callback: F, @@ -37,9 +34,11 @@ pub fn path_exists>(path: P) -> bool { } pub fn random_string(length: usize) -> String { - let chars = b"abcdefghijklmnopqrstuvwxyz0123456789_"; + use rand::Rng; + const CHARSET: &[u8] = b"abcdefghijklmnopqrstuvwxyz0123456789_"; + let mut rng = rand::thread_rng(); (0..length) - .map(|_| from_u32(u32::from(chars[random::() % chars.len()])).unwrap()) + .map(|_| char::from(CHARSET[rng.gen_range(0, CHARSET.len())])) .collect() } From 54ad422fa61ff70b17aaf1bb454a5c51cc9a0a1d Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sat, 13 Apr 2019 18:52:00 +0700 Subject: [PATCH 6/8] cargo: Sort deps according to alphabet order --- Cargo.lock | 44 ++++++++++++++++++++++---------------------- Cargo.toml | 18 +++++++++--------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 22809b95ae..51f75614d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,7 +78,7 @@ dependencies = [ "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -115,7 +115,7 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.7.0" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "block-padding 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -360,7 +360,7 @@ dependencies = [ "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "reqwest 0.9.14 (registry+https://github.com/rust-lang/crates.io-index)", + "reqwest 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -411,7 +411,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -516,7 +516,7 @@ dependencies = [ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -981,7 +981,7 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1147,7 +1147,7 @@ dependencies = [ [[package]] name = "regex" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1180,7 +1180,7 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.9.14" +version = "0.9.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1199,7 +1199,7 @@ dependencies = [ "native-tls 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_urlencoded 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "socks 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1213,7 +1213,7 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1240,7 +1240,7 @@ dependencies = [ "markdown 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.10.20 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1342,7 +1342,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1357,7 +1357,7 @@ dependencies = [ [[package]] name = "serde_urlencoded" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1371,7 +1371,7 @@ name = "sha2" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "block-buffer 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1431,7 +1431,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "0.15.30" +version = "0.15.31" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1446,7 +1446,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1897,7 +1897,7 @@ dependencies = [ "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" -"checksum block-buffer 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49665c62e0e700857531fa5d3763e91b539ff1abeebd56808d378b495870d60d" +"checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" "checksum block-padding 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d75255892aeb580d3c566f213a2b6fdc1c66667839f45719ee1d30ebf2aea591" "checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" @@ -2012,12 +2012,12 @@ dependencies = [ "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe5204c3a17e97dde73f285d49be585df59ed84b50a872baf416e73b62c3828" "checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" -"checksum regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "559008764a17de49a3146b234641644ed37d118d1ef641a0bb573d146edc6ce0" +"checksum regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8f0a0bcab2fd7d1d7c54fa9eae6f43eddeb9ce2e7352f8518a814a4f65d60c58" "checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" "checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" -"checksum reqwest 0.9.14 (registry+https://github.com/rust-lang/crates.io-index)" = "19c4c4990514fbd7a80380b826d81368ba6f6af61007ea142519ce47d72f6b0f" -"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" +"checksum reqwest 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)" = "943b9f85622f53bcf71721e0996f23688e3942e51fc33766c2e24a959316767b" +"checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" @@ -2032,7 +2032,7 @@ dependencies = [ "checksum serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "aa5f7c20820475babd2c077c3ab5f8c77a31c15e16ea38687b4c02d3e48680f4" "checksum serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "58fc82bec244f168b23d1963b45c8bf5726e9a15a9d146a067f9081aeed2de79" "checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" -"checksum serde_urlencoded 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d48f9f99cd749a2de71d29da5f948de7f2764cc5a9d7f3c97e3514d4ee6eabf2" +"checksum serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" "checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" @@ -2042,7 +2042,7 @@ dependencies = [ "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b639411d0b9c738748b5397d5ceba08e648f4f1992231aa859af1a017f31f60b" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" -"checksum syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)" = "66c8865bf5a7cbb662d8b011950060b3c8743dca141b054bf7195b20d314d8e2" +"checksum syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)" = "d2b4cfac95805274c6afdb12d8f770fa2d27c045953e7b630a81801953699a9a" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum tar 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)" = "c2167ff53da2a661702b3299f71a91b61b1dffef36b4b2884b1f9c67254c0133" "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" diff --git a/Cargo.toml b/Cargo.toml index 553d7114c7..47f90d7345 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,20 +20,26 @@ vendored-openssl = ['openssl/vendored'] # Include in the default set to disable self-update and uninstall. no-self-update = [] +# Sorted by alphabetic order [dependencies] +clap = "2" dirs = "1" download = { path = "download" } -clap = "2" error-chain = "0.12" flate2 = "1" +git-testament = "0.1.4" +lazy_static = "1" libc = "0.2" markdown = "0.2" +# Used by `curl` or `reqwest` backend although it isn't imported +# by our rustup. +openssl = { version = "0.10", optional = true } rand = "0.6" regex = "1" remove_dir_all = "0.5.1" same-file = "1" -semver = "0.9" scopeguard = "1" +semver = "0.9" sha2 = "0.8" tar = "0.4" tempdir = "0.3.4" @@ -44,17 +50,11 @@ url = "1" wait-timeout = "0.2" walkdir = "2" xz2 = "0.1.3" -openssl = { version = "0.10", optional = true } -git-testament = "0.1.4" -lazy_static = "1" [target."cfg(windows)".dependencies] +cc = "1" winapi = { version = "0.3", features = ["combaseapi", "errhandlingapi", "fileapi", "handleapi", "ioapiset", "jobapi", "jobapi2", "minwindef", "processthreadsapi", "psapi", "shlobj", "shtypes", "synchapi", "sysinfoapi", "tlhelp32", "userenv", "winbase", "winerror", "winioctl", "winnt", "winuser"] } winreg = "0.6" -cc = "1" - -[dev-dependencies] -lazy_static = "1" [workspace] members = ["download"] From c9f7b791811926205c55af8dabcb206c991ecbba Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 14 Apr 2019 12:40:40 +0700 Subject: [PATCH 7/8] perf: Use lazy_static with regex --- src/cli/self_update.rs | 11 +++++++--- src/dist/dist.rs | 49 +++++++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/cli/self_update.rs b/src/cli/self_update.rs index 595ef42f90..a3deffc755 100644 --- a/src/cli/self_update.rs +++ b/src/cli/self_update.rs @@ -33,7 +33,6 @@ use crate::common::{self, Confirm}; use crate::errors::*; use crate::term2; -use regex::Regex; use rustup::dist::dist; use rustup::utils::utils; use rustup::{DUP_TOOLS, TOOLS}; @@ -1378,8 +1377,14 @@ fn get_new_rustup_version(path: &Path) -> Option { } fn parse_new_rustup_version(version: String) -> String { - let re = Regex::new(r"\d+.\d+.\d+[0-9a-zA-Z-]*").unwrap(); - let capture = re.captures(&version); + use lazy_static::lazy_static; + use regex::Regex; + + lazy_static! { + static ref RE: Regex = Regex::new(r"\d+.\d+.\d+[0-9a-zA-Z-]*").unwrap(); + } + + let capture = RE.captures(&version); let matched_version = match capture { Some(cap) => cap.get(0).unwrap().as_str(), None => "(unknown)", diff --git a/src/dist/dist.rs b/src/dist/dist.rs index 6e7843cc1e..8964ada3a1 100644 --- a/src/dist/dist.rs +++ b/src/dist/dist.rs @@ -8,6 +8,7 @@ use crate::dist::temp; use crate::errors::*; use crate::utils::utils; +use lazy_static::lazy_static; use regex::Regex; use std::env; @@ -223,15 +224,16 @@ impl PartialTargetTriple { // we can count on all triple components being // delineated by it. let name = format!("-{}", name); - let pattern = format!( - r"^(?:-({}))?(?:-({}))?(?:-({}))?$", - LIST_ARCHS.join("|"), - LIST_OSES.join("|"), - LIST_ENVS.join("|") - ); - - let re = Regex::new(&pattern).unwrap(); - re.captures(&name).map(|c| { + lazy_static! { + static ref PATTERN: String = format!( + r"^(?:-({}))?(?:-({}))?(?:-({}))?$", + LIST_ARCHS.join("|"), + LIST_OSES.join("|"), + LIST_ENVS.join("|") + ); + static ref RE: Regex = Regex::new(&PATTERN).unwrap(); + } + RE.captures(&name).map(|c| { fn fn_map(s: &str) -> Option { if s == "" { None @@ -259,13 +261,14 @@ impl PartialToolchainDesc { r"\d{1}\.\d{2}\.\d{1}", ]; - let pattern = format!( - r"^({})(?:-(\d{{4}}-\d{{2}}-\d{{2}}))?(?:-(.*))?$", - CHANNELS.join("|") - ); - - let re = Regex::new(&pattern).unwrap(); - let d = re.captures(name).map(|c| { + lazy_static! { + static ref PATTERN: String = format!( + r"^({})(?:-(\d{{4}}-\d{{2}}-\d{{2}}))?(?:-(.*))?$", + CHANNELS.join("|") + ); + static ref RE: Regex = Regex::new(&PATTERN).unwrap(); + } + let d = RE.captures(name).map(|c| { fn fn_map(s: &str) -> Option { if s == "" { None @@ -349,13 +352,15 @@ impl ToolchainDesc { r"\d{1}\.\d{2}\.\d{1}", ]; - let pattern = format!( - r"^({})(?:-(\d{{4}}-\d{{2}}-\d{{2}}))?-(.*)?$", - CHANNELS.join("|"), - ); + lazy_static! { + static ref PATTERN: String = format!( + r"^({})(?:-(\d{{4}}-\d{{2}}-\d{{2}}))?-(.*)?$", + CHANNELS.join("|"), + ); + static ref RE: Regex = Regex::new(&PATTERN).unwrap(); + } - let re = Regex::new(&pattern).unwrap(); - re.captures(name) + RE.captures(name) .map(|c| { fn fn_map(s: &str) -> Option { if s == "" { From ffce6176ce8ecf69b72ab770f111c51a325db920 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Wed, 17 Apr 2019 04:30:08 +0700 Subject: [PATCH 8/8] cli/self_update: Fix error when casting to `char*` --- src/cli/self_update.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/self_update.rs b/src/cli/self_update.rs index a3deffc755..1fa770686a 100644 --- a/src/cli/self_update.rs +++ b/src/cli/self_update.rs @@ -463,7 +463,7 @@ fn do_anti_sudo_check(no_prompt: bool) -> Result<()> { libc::getpwuid_r( libc::geteuid(), &mut pwd, - &mut buf as *mut [u8] as *mut i8, + &mut buf as *mut [u8] as *mut libc::c_char, buf.len(), &mut pwdp, )