Skip to content

Commit

Permalink
Auto merge of #1261 - alanhdu:master, r=alexcrichton
Browse files Browse the repository at this point in the history
Update dependencies

- Use `toml 0.4` instead of `toml 0.1`
- Use `serde` instead of `rustc-serialize`
- Use `lazy_static 0.2` (over `0.1`)
- Upgrade to `error-chain 0.11` (to silence unused doc comment warnings).
  • Loading branch information
bors committed Sep 30, 2017
2 parents 80f9ec7 + eabcd62 commit 533f098
Show file tree
Hide file tree
Showing 20 changed files with 175 additions and 148 deletions.
110 changes: 77 additions & 33 deletions Cargo.lock

Large diffs are not rendered by default.

24 changes: 13 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,26 @@ msi-installed = []
rustup-dist = { path = "src/rustup-dist" }
rustup-utils = { path = "src/rustup-utils" }
download = { path = "src/download" }
error-chain = "0.10"
clap = "2.18.0"
regex = "0.2"
url = "1.1.0"
term = "0.4.4"
error-chain = "0.11"
itertools = "0.6"
time = "0.1.34"
tempdir = "0.3.4"
tempfile = "2.1.4"
libc = "0.2.0"
rand = "0.3.11"
markdown = "0.2"
rustc-serialize = "0.3"
rand = "0.3.11"
regex = "0.2"
remove_dir_all = "0.2.0"
scopeguard = "0.3"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
sha2 = "0.6.0"
toml = "0.1"
tempdir = "0.3.4"
tempfile = "2.1.4"
term = "0.4.4"
time = "0.1.34"
toml = "0.4"
url = "1.1.0"
wait-timeout = "0.1.5"
remove_dir_all = "0.2.0"

[target."cfg(windows)".dependencies]
winapi = "0.2.8"
Expand Down
4 changes: 2 additions & 2 deletions src/download/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ curl-backend = ["curl"]
reqwest-backend = ["reqwest", "env_proxy", "lazy_static"]

[dependencies]
error-chain = "0.10"
error-chain = "0.11"
url = "1.2"
curl = { version = "0.4.6", optional = true }
env_proxy = { version = "0.1.1", optional = true }
lazy_static = { version = "0.1", optional = true }
lazy_static = { version = "0.2", optional = true }
reqwest = { version = "0.7.3", optional = true }

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions src/rustup-cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1377,8 +1377,8 @@ pub fn prepare_update() -> Result<Option<PathBuf>> {
let release_file = tempdir.path().join("release-stable.toml");
try!(utils::download_file(&release_file_url, &release_file, None, &|_| ()));
let release_toml_str = try!(utils::read_file("rustup release", &release_file));
let release_toml = try!(toml::Parser::new(&release_toml_str).parse()
.ok_or(Error::from("unable to parse rustup release file")));
let release_toml: toml::Value = try!(toml::from_str(&release_toml_str)
.map_err(|_| Error::from("unable to parse rustup release file")));
let schema = try!(release_toml.get("schema-version")
.ok_or(Error::from("no schema key in rustup release file")));
let schema = try!(schema.as_str()
Expand Down
6 changes: 3 additions & 3 deletions src/rustup-dist/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ url = "1.1.0"
tar = "0.4.0"
flate2 = "0.2.9"
xz2 = "0.1.3"
tempdir = "0.3.4"
walkdir = "1.0"
toml = "0.1.27"
toml = "0.4"
sha2 = "0.6.0"
remove_dir_all = "0.2"
rustup-utils = { path = "../rustup-utils" }
error-chain = "0.10"
error-chain = "0.11"

[dev-dependencies]
rustup-mock = { path = "../rustup-mock" }
tempdir = "0.3.4"

[target."cfg(windows)".dependencies]
winapi = "0.2.8"
Expand Down
16 changes: 7 additions & 9 deletions src/rustup-dist/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct Config {
}

impl Config {
pub fn from_toml(mut table: toml::Table, path: &str) -> Result<Self> {
pub fn from_toml(mut table: toml::value::Table, path: &str) -> Result<Self> {
let version = try!(get_string(&mut table, "config_version", path));
if !SUPPORTED_CONFIG_VERSIONS.contains(&&*version) {
return Err(ErrorKind::UnsupportedVersion(version).into());
Expand All @@ -29,8 +29,8 @@ impl Config {
components: components,
})
}
pub fn to_toml(self) -> toml::Table {
let mut result = toml::Table::new();
pub fn to_toml(self) -> toml::value::Table {
let mut result = toml::value::Table::new();
result.insert("config_version".to_owned(),
toml::Value::String(self.config_version));
let components = Self::components_to_toml(self.components);
Expand All @@ -41,17 +41,15 @@ impl Config {
}

pub fn parse(data: &str) -> Result<Self> {
let mut parser = toml::Parser::new(data);
let value = try!(parser.parse().ok_or_else(move || ErrorKind::Parsing(parser.errors)));

let value = toml::from_str(data).map_err(ErrorKind::Parsing)?;
Self::from_toml(value, "")
}

pub fn stringify(self) -> String {
toml::Value::Table(self.to_toml()).to_string()
}

fn toml_to_components(arr: toml::Array, path: &str) -> Result<Vec<Component>> {
fn toml_to_components(arr: toml::value::Array, path: &str) -> Result<Vec<Component>> {
let mut result = Vec::new();

for (i, v) in arr.into_iter().enumerate() {
Expand All @@ -64,8 +62,8 @@ impl Config {
Ok(result)
}

fn components_to_toml(components: Vec<Component>) -> toml::Array {
let mut result = toml::Array::new();
fn components_to_toml(components: Vec<Component>) -> toml::value::Array {
let mut result = toml::value::Array::new();
for v in components {
result.push(toml::Value::Table(v.to_toml()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/rustup-dist/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ error_chain! {
}
})
}
Parsing(e: Vec<toml::ParserError>) {
Parsing(e: toml::de::Error) {
description("error parsing manifest")
}
UnsupportedVersion(v: String) {
Expand Down
1 change: 0 additions & 1 deletion src/rustup-dist/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

extern crate regex;
extern crate itertools;
extern crate tempdir;
extern crate walkdir;
extern crate toml;
extern crate flate2;
Expand Down
56 changes: 27 additions & 29 deletions src/rustup-dist/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ pub struct Component {

impl Manifest {
pub fn parse(data: &str) -> Result<Self> {
let mut parser = toml::Parser::new(data);
let value = try!(parser.parse().ok_or_else(move || ErrorKind::Parsing(parser.errors)));

let manifest = try!(Self::from_toml(value, ""));
let value = toml::from_str(data).map_err(ErrorKind::Parsing)?;
let manifest = Self::from_toml(value, "")?;
try!(manifest.validate());

Ok(manifest)
Expand All @@ -75,7 +73,7 @@ impl Manifest {
toml::Value::Table(self.to_toml()).to_string()
}

pub fn from_toml(mut table: toml::Table, path: &str) -> Result<Self> {
pub fn from_toml(mut table: toml::value::Table, path: &str) -> Result<Self> {
let version = try!(get_string(&mut table, "manifest-version", path));
if !SUPPORTED_MANIFEST_VERSIONS.contains(&&*version) {
return Err(ErrorKind::UnsupportedVersion(version).into());
Expand All @@ -87,8 +85,8 @@ impl Manifest {
renames: try!(Self::table_to_renames(table, path)),
})
}
pub fn to_toml(self) -> toml::Table {
let mut result = toml::Table::new();
pub fn to_toml(self) -> toml::value::Table {
let mut result = toml::value::Table::new();

result.insert("date".to_owned(), toml::Value::String(self.date));
result.insert("manifest-version".to_owned(),
Expand All @@ -103,7 +101,7 @@ impl Manifest {
result
}

fn table_to_packages(table: &mut toml::Table, path: &str) -> Result<HashMap<String, Package>> {
fn table_to_packages(table: &mut toml::value::Table, path: &str) -> Result<HashMap<String, Package>> {
let mut result = HashMap::new();
let pkg_table = try!(get_table(table, "pkg", path));

Expand All @@ -115,15 +113,15 @@ impl Manifest {

Ok(result)
}
fn packages_to_table(packages: HashMap<String, Package>) -> toml::Table {
let mut result = toml::Table::new();
fn packages_to_table(packages: HashMap<String, Package>) -> toml::value::Table {
let mut result = toml::value::Table::new();
for (k, v) in packages {
result.insert(k, toml::Value::Table(v.to_toml()));
}
result
}

fn table_to_renames(mut table: toml::Table, path: &str) -> Result<HashMap<String, String>> {
fn table_to_renames(mut table: toml::value::Table, path: &str) -> Result<HashMap<String, String>> {
let mut result = HashMap::new();
let rename_table = try!(get_table(&mut table, "rename", path));

Expand All @@ -135,10 +133,10 @@ impl Manifest {

Ok(result)
}
fn renames_to_table(renames: HashMap<String, String>) -> toml::Table {
let mut result = toml::Table::new();
fn renames_to_table(renames: HashMap<String, String>) -> toml::value::Table {
let mut result = toml::value::Table::new();
for (from, to) in renames {
let mut table = toml::Table::new();
let mut table = toml::value::Table::new();
table.insert("to".to_owned(), toml::Value::String(to));
result.insert(from, toml::Value::Table(table));
}
Expand Down Expand Up @@ -190,14 +188,14 @@ impl Manifest {
}

impl Package {
pub fn from_toml(mut table: toml::Table, path: &str) -> Result<Self> {
pub fn from_toml(mut table: toml::value::Table, path: &str) -> Result<Self> {
Ok(Package {
version: try!(get_string(&mut table, "version", path)),
targets: try!(Self::toml_to_targets(table, path)),
})
}
pub fn to_toml(self) -> toml::Table {
let mut result = toml::Table::new();
pub fn to_toml(self) -> toml::value::Table {
let mut result = toml::value::Table::new();

result.insert("version".to_owned(), toml::Value::String(self.version));

Expand All @@ -207,7 +205,7 @@ impl Package {
result
}

fn toml_to_targets(mut table: toml::Table, path: &str) -> Result<PackageTargets> {
fn toml_to_targets(mut table: toml::value::Table, path: &str) -> Result<PackageTargets> {
let mut target_table = try!(get_table(&mut table, "target", path));

if let Some(toml::Value::Table(t)) = target_table.remove("*") {
Expand All @@ -222,8 +220,8 @@ impl Package {
Ok(PackageTargets::Targeted(result))
}
}
fn targets_to_toml(targets: PackageTargets) -> toml::Table {
let mut result = toml::Table::new();
fn targets_to_toml(targets: PackageTargets) -> toml::value::Table {
let mut result = toml::value::Table::new();
match targets {
PackageTargets::Wildcard(tpkg) => {
result.insert("*".to_owned(), toml::Value::Table(tpkg.to_toml()));
Expand Down Expand Up @@ -268,7 +266,7 @@ impl PackageTargets {
}

impl TargetedPackage {
pub fn from_toml(mut table: toml::Table, path: &str) -> Result<Self> {
pub fn from_toml(mut table: toml::value::Table, path: &str) -> Result<Self> {
let components = try!(get_array(&mut table, "components", path));
let extensions = try!(get_array(&mut table, "extensions", path));

Expand All @@ -293,10 +291,10 @@ impl TargetedPackage {
})
}
}
pub fn to_toml(self) -> toml::Table {
pub fn to_toml(self) -> toml::value::Table {
let extensions = Self::components_to_toml(self.extensions);
let components = Self::components_to_toml(self.components);
let mut result = toml::Table::new();
let mut result = toml::value::Table::new();
if !extensions.is_empty() {
result.insert("extensions".to_owned(), toml::Value::Array(extensions));
}
Expand All @@ -321,7 +319,7 @@ impl TargetedPackage {
self.bins.is_some()
}

fn toml_to_components(arr: toml::Array, path: &str) -> Result<Vec<Component>> {
fn toml_to_components(arr: toml::value::Array, path: &str) -> Result<Vec<Component>> {
let mut result = Vec::new();

for (i, v) in arr.into_iter().enumerate() {
Expand All @@ -333,8 +331,8 @@ impl TargetedPackage {

Ok(result)
}
fn components_to_toml(components: Vec<Component>) -> toml::Array {
let mut result = toml::Array::new();
fn components_to_toml(components: Vec<Component>) -> toml::value::Array {
let mut result = toml::value::Array::new();
for v in components {
result.push(toml::Value::Table(v.to_toml()));
}
Expand All @@ -343,7 +341,7 @@ impl TargetedPackage {
}

impl Component {
pub fn from_toml(mut table: toml::Table, path: &str) -> Result<Self> {
pub fn from_toml(mut table: toml::value::Table, path: &str) -> Result<Self> {
Ok(Component {
pkg: try!(get_string(&mut table, "pkg", path)),
target: try!(get_string(&mut table, "target", path).map(|s| {
Expand All @@ -355,8 +353,8 @@ impl Component {
})),
})
}
pub fn to_toml(self) -> toml::Table {
let mut result = toml::Table::new();
pub fn to_toml(self) -> toml::value::Table {
let mut result = toml::value::Table::new();
result.insert("target".to_owned(), toml::Value::String(
self.target.map(|t| t.to_string()).unwrap_or_else(||"*".to_owned())
));
Expand Down
5 changes: 1 addition & 4 deletions src/rustup-mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@ repository = "https://github.com/rust-lang-nursery/rustup.rs"

[dependencies]
url = "1.1.0"
scopeguard = "0.3.0"
lazy_static = "0.2.0"
walkdir = "1.0.0"
flate2 = "0.2.9"
xz2 = "0.1.3"
tempdir = "0.3.4"
itertools = "0.6"
tar = "0.4.0"
toml = "0.1.27"
rustup-utils = { path = "../rustup-utils" }
toml = "0.4"
sha2 = "0.6.0"
wait-timeout = "0.1.3"

Expand Down
Loading

0 comments on commit 533f098

Please sign in to comment.