diff --git a/Cargo.lock b/Cargo.lock index 781bfea05f6..eb2efec0997 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,7 +8,7 @@ dependencies = [ "crates-io 0.10.0", "crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "curl 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "docopt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "docopt 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -18,6 +18,7 @@ dependencies = [ "git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "jobserver 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", @@ -27,7 +28,6 @@ dependencies = [ "num_cpus 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)", "psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -111,10 +111,10 @@ dependencies = [ "flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -191,12 +191,13 @@ dependencies = [ [[package]] name = "docopt" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -306,6 +307,11 @@ dependencies = [ "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "hex" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "idna" version = "0.1.2" @@ -883,7 +889,7 @@ dependencies = [ "checksum curl 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c90e1240ef340dd4027ade439e5c7c2064dd9dc652682117bd50d1486a3add7b" "checksum curl-sys 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)" = "f00c8ba847fb0730c293069b4d1203dc01bf3c2e1f90b4e55f426ed8f4a1eeac" "checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850" -"checksum docopt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab32ea6e284d87987066f21a9e809a73c14720571ef34516f0890b3d355ccfd8" +"checksum docopt 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63e408eee8a772c5c61f62353992e3ebf51ef5c832dd04d986b3dc7d48c5b440" "checksum dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80c8b71fd71146990a9742fc06dcbbde19161a267e0ad4e572c35162f4578c90" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" "checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" @@ -897,6 +903,7 @@ dependencies = [ "checksum git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "68676bc784bf0bef83278898929bf64a251e87c0340723d0b93fa096c9c5bf8e" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bf088f042a467089e9baa4972f57f9247e42a0cc549ba264c7a04fbb8ecb89d4" +"checksum hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6a22814455d41612f41161581c2883c0c6a1c41852729b17d5ed88f01e153aa" "checksum idna 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2233d4940b1f19f0418c158509cd7396b8d70a5db5705ce410914dc8fa603b37" "checksum itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2f404fbc66fd9aac13e998248505e7ecb2ad8e44ab6388684c5fb11c6c251c" "checksum jobserver 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c43fc6e4066b2adf0539c854daa1d926d7f23e6926e019850d34b8ae46391b2e" diff --git a/Cargo.toml b/Cargo.toml index 3435b05a51a..26401fbd40e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ path = "src/cargo/lib.rs" crates-io = { path = "src/crates-io", version = "0.10" } crossbeam = "0.2" curl = "0.4.6" -docopt = "0.7" +docopt = "0.8" env_logger = "0.4" error-chain = "0.10.0" filetime = "0.1" @@ -29,12 +29,12 @@ fs2 = "0.4" git2 = "0.6" git2-curl = "0.7" glob = "0.2" +hex = "0.2" jobserver = "0.1.4" libc = "0.2" libgit2-sys = "0.6" log = "0.3" num_cpus = "1.0" -rustc-serialize = "0.3" scoped-tls = "0.1" semver = { version = "0.7.0", features = ["serde"] } serde = "1.0" diff --git a/src/bin/bench.rs b/src/bin/bench.rs index c58ff5c087d..9e34f784725 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -3,7 +3,7 @@ use cargo::ops::{self, MessageFormat, Packages}; use cargo::util::{CliResult, CliError, Config, CargoErrorKind}; use cargo::util::important_paths::{find_root_manifest_for_wd}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_no_run: bool, flag_package: Vec, diff --git a/src/bin/build.rs b/src/bin/build.rs index 759c2746646..c679fc50f06 100644 --- a/src/bin/build.rs +++ b/src/bin/build.rs @@ -5,7 +5,7 @@ use cargo::ops::{self, CompileOptions, MessageFormat, Packages}; use cargo::util::important_paths::{find_root_manifest_for_wd}; use cargo::util::{CliResult, Config}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_package: Vec, flag_jobs: Option, diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index 23085116d02..ae4409723d4 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -2,7 +2,6 @@ extern crate cargo; extern crate url; extern crate env_logger; extern crate git2_curl; -extern crate rustc_serialize; extern crate toml; #[macro_use] extern crate log; @@ -20,7 +19,7 @@ use cargo::core::shell::{Verbosity, ColorConfig}; use cargo::util::{self, CliResult, lev_distance, Config, CargoResult, CargoError, CargoErrorKind}; use cargo::util::CliError; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Flags { flag_list: bool, flag_version: bool, diff --git a/src/bin/check.rs b/src/bin/check.rs index 147ff43b9a9..fd36f542000 100644 --- a/src/bin/check.rs +++ b/src/bin/check.rs @@ -49,7 +49,7 @@ the manifest. The default profile for this command is `dev`, but passing the --release flag will use the `release` profile instead. "; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_package: Vec, flag_jobs: Option, diff --git a/src/bin/clean.rs b/src/bin/clean.rs index 8903f890312..661425e9e37 100644 --- a/src/bin/clean.rs +++ b/src/bin/clean.rs @@ -5,7 +5,7 @@ use cargo::ops; use cargo::util::{CliResult, Config}; use cargo::util::important_paths::{find_root_manifest_for_wd}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_package: Vec, flag_target: Option, diff --git a/src/bin/doc.rs b/src/bin/doc.rs index 11e44670faf..6b4190985df 100644 --- a/src/bin/doc.rs +++ b/src/bin/doc.rs @@ -3,7 +3,7 @@ use cargo::ops::{self, MessageFormat, Packages}; use cargo::util::{CliResult, Config}; use cargo::util::important_paths::{find_root_manifest_for_wd}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_target: Option, flag_features: Vec, diff --git a/src/bin/fetch.rs b/src/bin/fetch.rs index 80aba98db92..6b61ba7d689 100644 --- a/src/bin/fetch.rs +++ b/src/bin/fetch.rs @@ -3,7 +3,7 @@ use cargo::ops; use cargo::util::{CliResult, Config}; use cargo::util::important_paths::find_root_manifest_for_wd; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_manifest_path: Option, flag_verbose: u32, diff --git a/src/bin/generate_lockfile.rs b/src/bin/generate_lockfile.rs index f545b1e26f7..60cb6c6566a 100644 --- a/src/bin/generate_lockfile.rs +++ b/src/bin/generate_lockfile.rs @@ -5,7 +5,7 @@ use cargo::ops; use cargo::util::{CliResult, Config}; use cargo::util::important_paths::find_root_manifest_for_wd; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_manifest_path: Option, flag_verbose: u32, diff --git a/src/bin/git_checkout.rs b/src/bin/git_checkout.rs index 4309f0163fe..4841b5e4ea6 100644 --- a/src/bin/git_checkout.rs +++ b/src/bin/git_checkout.rs @@ -2,7 +2,7 @@ use cargo::core::source::{Source, SourceId, GitReference}; use cargo::sources::git::{GitSource}; use cargo::util::{Config, CliResult, ToUrl}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_url: String, flag_reference: String, diff --git a/src/bin/help.rs b/src/bin/help.rs index f59e24f3ebd..c5059e4ff5e 100644 --- a/src/bin/help.rs +++ b/src/bin/help.rs @@ -1,6 +1,6 @@ use cargo::util::{CliResult, CliError, Config}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options; pub const USAGE: &'static str = " diff --git a/src/bin/init.rs b/src/bin/init.rs index 97dca61c9fe..be02789ec55 100644 --- a/src/bin/init.rs +++ b/src/bin/init.rs @@ -3,7 +3,7 @@ use std::env; use cargo::ops; use cargo::util::{CliResult, Config}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_verbose: u32, flag_quiet: Option, diff --git a/src/bin/install.rs b/src/bin/install.rs index 197dcdd1be0..8d532e6bc1c 100644 --- a/src/bin/install.rs +++ b/src/bin/install.rs @@ -2,7 +2,7 @@ use cargo::ops; use cargo::core::{SourceId, GitReference}; use cargo::util::{CliResult, Config, ToUrl}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_jobs: Option, flag_features: Vec, diff --git a/src/bin/locate_project.rs b/src/bin/locate_project.rs index 7c7727aa221..e0c6164e7c7 100644 --- a/src/bin/locate_project.rs +++ b/src/bin/locate_project.rs @@ -2,7 +2,7 @@ use cargo; use cargo::util::{CliResult, CliError, Config}; use cargo::util::important_paths::{find_root_manifest_for_wd}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct LocateProjectFlags { flag_manifest_path: Option, } diff --git a/src/bin/login.rs b/src/bin/login.rs index 6e7841717b6..a9d6b1a710a 100644 --- a/src/bin/login.rs +++ b/src/bin/login.rs @@ -6,7 +6,7 @@ use cargo::core::{SourceId, Source}; use cargo::sources::RegistrySource; use cargo::util::{CliResult, CargoResultExt, Config}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_host: Option, arg_token: Option, diff --git a/src/bin/metadata.rs b/src/bin/metadata.rs index 00d46c0059d..0811535307b 100644 --- a/src/bin/metadata.rs +++ b/src/bin/metadata.rs @@ -4,7 +4,7 @@ use cargo::ops::{output_metadata, OutputMetadataOptions}; use cargo::util::important_paths::find_root_manifest_for_wd; use cargo::util::{CliResult, Config}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_color: Option, flag_features: Vec, diff --git a/src/bin/new.rs b/src/bin/new.rs index aeee334a965..bcf446c967c 100644 --- a/src/bin/new.rs +++ b/src/bin/new.rs @@ -3,7 +3,7 @@ use std::env; use cargo::ops; use cargo::util::{CliResult, Config}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_verbose: u32, flag_quiet: Option, diff --git a/src/bin/owner.rs b/src/bin/owner.rs index 288d13e302c..587a968a6bf 100644 --- a/src/bin/owner.rs +++ b/src/bin/owner.rs @@ -1,7 +1,7 @@ use cargo::ops; use cargo::util::{CliResult, Config}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { arg_crate: Option, flag_token: Option, diff --git a/src/bin/package.rs b/src/bin/package.rs index df342fbf8bf..e4c4af44968 100644 --- a/src/bin/package.rs +++ b/src/bin/package.rs @@ -3,7 +3,7 @@ use cargo::ops; use cargo::util::{CliResult, Config}; use cargo::util::important_paths::find_root_manifest_for_wd; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_verbose: u32, flag_quiet: Option, diff --git a/src/bin/pkgid.rs b/src/bin/pkgid.rs index ea573361d9e..f8574139458 100644 --- a/src/bin/pkgid.rs +++ b/src/bin/pkgid.rs @@ -3,7 +3,7 @@ use cargo::ops; use cargo::util::{CliResult, Config}; use cargo::util::important_paths::{find_root_manifest_for_wd}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_verbose: u32, flag_quiet: Option, diff --git a/src/bin/publish.rs b/src/bin/publish.rs index dcba4df07e2..3f0af0baaf7 100644 --- a/src/bin/publish.rs +++ b/src/bin/publish.rs @@ -3,7 +3,7 @@ use cargo::ops; use cargo::util::{CliResult, Config}; use cargo::util::important_paths::find_root_manifest_for_wd; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_host: Option, flag_token: Option, diff --git a/src/bin/read_manifest.rs b/src/bin/read_manifest.rs index 07c4a5f2c45..c97456757d5 100644 --- a/src/bin/read_manifest.rs +++ b/src/bin/read_manifest.rs @@ -5,7 +5,7 @@ use cargo::core::Package; use cargo::util::{CliResult, Config}; use cargo::util::important_paths::{find_root_manifest_for_wd}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_manifest_path: Option, flag_color: Option, diff --git a/src/bin/run.rs b/src/bin/run.rs index 96c51bea240..3ff26fc6212 100644 --- a/src/bin/run.rs +++ b/src/bin/run.rs @@ -5,7 +5,7 @@ use cargo::ops::{self, MessageFormat, Packages}; use cargo::util::{CliResult, CliError, Config, CargoErrorKind}; use cargo::util::important_paths::{find_root_manifest_for_wd}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_bin: Option, flag_example: Option, diff --git a/src/bin/rustc.rs b/src/bin/rustc.rs index 3ee18a86234..0616e6f5e08 100644 --- a/src/bin/rustc.rs +++ b/src/bin/rustc.rs @@ -5,7 +5,7 @@ use cargo::ops::{self, CompileOptions, CompileMode, MessageFormat, Packages}; use cargo::util::important_paths::{find_root_manifest_for_wd}; use cargo::util::{CliResult, CliError, Config}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { arg_opts: Option>, flag_package: Option, diff --git a/src/bin/rustdoc.rs b/src/bin/rustdoc.rs index b6a8e640e2b..55ce9c89d61 100644 --- a/src/bin/rustdoc.rs +++ b/src/bin/rustdoc.rs @@ -3,7 +3,7 @@ use cargo::ops::{self, MessageFormat, Packages}; use cargo::util::{CliResult, Config}; use cargo::util::important_paths::{find_root_manifest_for_wd}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { arg_opts: Vec, flag_target: Option, diff --git a/src/bin/search.rs b/src/bin/search.rs index 47879cae582..c9794ad3e41 100644 --- a/src/bin/search.rs +++ b/src/bin/search.rs @@ -3,7 +3,7 @@ use cargo::util::{CliResult, Config}; use std::cmp; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_host: Option, flag_verbose: u32, diff --git a/src/bin/test.rs b/src/bin/test.rs index 5fbae53f373..fe8d5757f8c 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -3,7 +3,7 @@ use cargo::ops::{self, MessageFormat, Packages}; use cargo::util::{CliResult, CliError, Config, CargoErrorKind}; use cargo::util::important_paths::find_root_manifest_for_wd; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { arg_args: Vec, flag_features: Vec, diff --git a/src/bin/uninstall.rs b/src/bin/uninstall.rs index 725452251e1..619b029f511 100644 --- a/src/bin/uninstall.rs +++ b/src/bin/uninstall.rs @@ -1,7 +1,7 @@ use cargo::ops; use cargo::util::{CliResult, Config}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_bin: Vec, flag_root: Option, diff --git a/src/bin/update.rs b/src/bin/update.rs index e8da2bd5cbc..1890ab7cc61 100644 --- a/src/bin/update.rs +++ b/src/bin/update.rs @@ -5,7 +5,7 @@ use cargo::ops; use cargo::util::{CliResult, Config}; use cargo::util::important_paths::find_root_manifest_for_wd; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { flag_package: Vec, flag_aggressive: bool, diff --git a/src/bin/verify_project.rs b/src/bin/verify_project.rs index 26e11f96644..ea03bdd58c4 100644 --- a/src/bin/verify_project.rs +++ b/src/bin/verify_project.rs @@ -9,7 +9,7 @@ use cargo::util::{CliResult, Config}; use serde_json; use toml; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Flags { flag_manifest_path: Option, flag_verbose: u32, diff --git a/src/bin/version.rs b/src/bin/version.rs index 9724481036a..a97c0fc0300 100644 --- a/src/bin/version.rs +++ b/src/bin/version.rs @@ -3,8 +3,8 @@ use std::env; use cargo; use cargo::util::{CliResult, Config}; -#[derive(RustcDecodable)] -pub struct Options; +#[derive(Deserialize)] +pub struct Options {} pub const USAGE: &'static str = " Show version information diff --git a/src/bin/yank.rs b/src/bin/yank.rs index 9e5663684ab..de48639ecff 100644 --- a/src/bin/yank.rs +++ b/src/bin/yank.rs @@ -1,7 +1,7 @@ use cargo::ops; use cargo::util::{CliResult, Config}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct Options { arg_crate: Option, flag_token: Option, diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index 2fe2a572b13..38ebe82ae52 100755 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -17,11 +17,11 @@ extern crate flate2; extern crate fs2; extern crate git2; extern crate glob; +extern crate hex; extern crate jobserver; extern crate libc; extern crate libgit2_sys; extern crate num_cpus; -extern crate rustc_serialize; extern crate semver; extern crate serde; extern crate serde_ignored; @@ -37,7 +37,7 @@ use std::fmt; use std::error::Error; use error_chain::ChainedError; -use rustc_serialize::Decodable; +use serde::Deserialize; use serde::ser; use docopt::Docopt; @@ -105,7 +105,7 @@ impl fmt::Display for VersionInfo { } } -pub fn call_main_without_stdin( +pub fn call_main_without_stdin<'de, Flags: Deserialize<'de>>( exec: fn(Flags, &Config) -> CliResult, config: &Config, usage: &str, @@ -117,7 +117,7 @@ pub fn call_main_without_stdin( .argv(args.iter().map(|s| &s[..])) .help(true); - let flags = docopt.decode().map_err(|e| { + let flags = docopt.deserialize().map_err(|e| { let code = if e.fatal() {1} else {0}; CliError::new(e.to_string().into(), code) })?; diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 888939a2203..377fc8bc73e 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -96,7 +96,7 @@ pub enum CompileMode { Doctest, } -#[derive(Clone, Copy, PartialEq, Eq, RustcDecodable)] +#[derive(Clone, Copy, PartialEq, Eq, Deserialize)] pub enum MessageFormat { Human, Json diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index 846e7c0d444..ad049e494e4 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -3,7 +3,8 @@ use std::fs; use std::path::Path; use std::collections::BTreeMap; -use rustc_serialize::{Decodable, Decoder}; +use serde::{Deserialize, Deserializer}; +use serde::de; use git2::Config as GitConfig; use git2::Repository as GitRepository; @@ -43,16 +44,17 @@ struct MkOptions<'a> { bin: bool, } -impl Decodable for VersionControl { - fn decode(d: &mut D) -> Result { - Ok(match &d.read_str()?[..] { +impl<'de> Deserialize<'de> for VersionControl { + fn deserialize>(d: D) -> Result { + Ok(match &String::deserialize(d)?[..] { "git" => VersionControl::Git, "hg" => VersionControl::Hg, "pijul" => VersionControl::Pijul, "none" => VersionControl::NoVcs, n => { - let err = format!("could not decode '{}' as version control", n); - return Err(d.error(&err)); + let value = de::Unexpected::Str(n); + let msg = "unsupported version control system"; + return Err(de::Error::invalid_value(value, &msg)); } }) } diff --git a/src/cargo/sources/directory.rs b/src/cargo/sources/directory.rs index d0461315611..bf025177875 100644 --- a/src/cargo/sources/directory.rs +++ b/src/cargo/sources/directory.rs @@ -4,7 +4,8 @@ use std::fs::File; use std::io::Read; use std::path::{Path, PathBuf}; -use rustc_serialize::hex::ToHex; +use hex::ToHex; + use serde_json; use core::{Package, PackageId, Summary, SourceId, Source, Dependency, Registry}; diff --git a/src/cargo/sources/registry/local.rs b/src/cargo/sources/registry/local.rs index 203f3bc2560..5803fd77d94 100644 --- a/src/cargo/sources/registry/local.rs +++ b/src/cargo/sources/registry/local.rs @@ -2,9 +2,8 @@ use std::io::SeekFrom; use std::io::prelude::*; use std::path::Path; -use rustc_serialize::hex::ToHex; - use core::PackageId; +use hex::ToHex; use sources::registry::{RegistryData, RegistryConfig}; use util::FileLock; use util::paths; diff --git a/src/cargo/sources/registry/remote.rs b/src/cargo/sources/registry/remote.rs index 37b776b6d15..2f9f7c87e56 100644 --- a/src/cargo/sources/registry/remote.rs +++ b/src/cargo/sources/registry/remote.rs @@ -6,7 +6,7 @@ use std::path::Path; use curl::easy::{Easy, List}; use git2; -use rustc_serialize::hex::ToHex; +use hex::ToHex; use serde_json; use url::Url; diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index fa1f07c6bfe..32976225b76 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -15,7 +15,7 @@ use std::sync::{Once, ONCE_INIT}; use core::MultiShell; use core::shell::{Verbosity, ColorConfig}; use jobserver; -use rustc_serialize::{Encodable,Encoder}; +use serde::{Serialize, Serializer}; use toml; use util::Rustc; use util::errors::{CargoResult, CargoResultExt, CargoError, internal}; @@ -572,17 +572,17 @@ impl fmt::Debug for ConfigValue { } } -impl Encodable for ConfigValue { - fn encode(&self, s: &mut S) -> Result<(), S::Error> { +impl Serialize for ConfigValue { + fn serialize(&self, s: S) -> Result { match *self { - CV::String(ref string, _) => string.encode(s), + CV::String(ref string, _) => string.serialize(s), CV::List(ref list, _) => { let list: Vec<&String> = list.iter().map(|s| &s.0).collect(); - list.encode(s) + list.serialize(s) } - CV::Table(ref table, _) => table.encode(s), - CV::Boolean(b, _) => b.encode(s), - CV::Integer(i, _) => i.encode(s), + CV::Table(ref table, _) => table.serialize(s), + CV::Boolean(b, _) => b.serialize(s), + CV::Integer(i, _) => i.serialize(s), } } } diff --git a/src/cargo/util/hex.rs b/src/cargo/util/hex.rs index 28fed76fc0f..71a4c112fd3 100644 --- a/src/cargo/util/hex.rs +++ b/src/cargo/util/hex.rs @@ -1,9 +1,8 @@ #![allow(deprecated)] +use hex::ToHex; use std::hash::{Hasher, Hash, SipHasher}; -use rustc_serialize::hex::ToHex; - pub fn to_hex(num: u64) -> String { [ (num >> 0) as u8, diff --git a/tests/cargotest/Cargo.toml b/tests/cargotest/Cargo.toml index e5c29f95ddd..f5b1cc8ca30 100644 --- a/tests/cargotest/Cargo.toml +++ b/tests/cargotest/Cargo.toml @@ -13,10 +13,10 @@ filetime = "0.1" flate2 = "0.2" git2 = { version = "0.6", default-features = false } hamcrest = "=0.1.1" +hex = "0.2" kernel32-sys = "0.2" libc = "0.2" log = "0.3" -rustc-serialize = "0.3" serde = "1.0" serde_json = "1.0" tar = { version = "0.4", default-features = false } diff --git a/tests/cargotest/lib.rs b/tests/cargotest/lib.rs index 33e58c0e2e5..919768c1887 100644 --- a/tests/cargotest/lib.rs +++ b/tests/cargotest/lib.rs @@ -6,8 +6,8 @@ extern crate filetime; extern crate flate2; extern crate git2; extern crate hamcrest; +extern crate hex; extern crate libc; -extern crate rustc_serialize; extern crate serde; #[macro_use] extern crate serde_json; diff --git a/tests/cargotest/support/registry.rs b/tests/cargotest/support/registry.rs index 3eae9432992..49ab9390175 100644 --- a/tests/cargotest/support/registry.rs +++ b/tests/cargotest/support/registry.rs @@ -6,7 +6,7 @@ use std::path::{PathBuf, Path}; use flate2::Compression::Default; use flate2::write::GzEncoder; use git2; -use rustc_serialize::hex::ToHex; +use hex::ToHex; use tar::{Builder, Header}; use url::Url; diff --git a/tests/directory.rs b/tests/directory.rs index 8ff54c1476e..96c520f5f7c 100644 --- a/tests/directory.rs +++ b/tests/directory.rs @@ -1,15 +1,15 @@ #[macro_use] extern crate cargotest; extern crate hamcrest; -extern crate rustc_serialize; +#[macro_use] +extern crate serde_derive; +extern crate serde_json; use std::collections::HashMap; use std::fs::{self, File}; use std::io::prelude::*; use std::str; -use rustc_serialize::json; - use cargotest::cargo_process; use cargotest::support::{project, execs, ProjectBuilder}; use cargotest::support::paths; @@ -33,7 +33,7 @@ struct VendorPackage { cksum: Checksum, } -#[derive(RustcEncodable)] +#[derive(Serialize)] struct Checksum { package: String, files: HashMap, @@ -58,7 +58,7 @@ impl VendorPackage { fn build(&mut self) { let p = self.p.take().unwrap(); - let json = json::encode(&self.cksum).unwrap(); + let json = serde_json::to_string(&self.cksum).unwrap(); let p = p.file(".cargo-checksum.json", &json); p.build(); } diff --git a/tests/version.rs b/tests/version.rs index bc8c0c1b94c..57844c90a7c 100644 --- a/tests/version.rs +++ b/tests/version.rs @@ -1,7 +1,6 @@ extern crate cargo; extern crate cargotest; extern crate hamcrest; -extern crate rustc_serialize; use cargotest::support::{project, execs}; use hamcrest::assert_that;