Skip to content

Commit 533f098

Browse files
committed
Auto merge of #1261 - alanhdu:master, r=alexcrichton
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).
2 parents 80f9ec7 + eabcd62 commit 533f098

20 files changed

+175
-148
lines changed

Cargo.lock

Lines changed: 77 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,26 @@ msi-installed = []
3434
rustup-dist = { path = "src/rustup-dist" }
3535
rustup-utils = { path = "src/rustup-utils" }
3636
download = { path = "src/download" }
37-
error-chain = "0.10"
3837
clap = "2.18.0"
39-
regex = "0.2"
40-
url = "1.1.0"
41-
term = "0.4.4"
38+
error-chain = "0.11"
4239
itertools = "0.6"
43-
time = "0.1.34"
44-
tempdir = "0.3.4"
45-
tempfile = "2.1.4"
4640
libc = "0.2.0"
47-
rand = "0.3.11"
4841
markdown = "0.2"
49-
rustc-serialize = "0.3"
42+
rand = "0.3.11"
43+
regex = "0.2"
44+
remove_dir_all = "0.2.0"
5045
scopeguard = "0.3"
46+
serde = "1.0"
47+
serde_derive = "1.0"
48+
serde_json = "1.0"
5149
sha2 = "0.6.0"
52-
toml = "0.1"
50+
tempdir = "0.3.4"
51+
tempfile = "2.1.4"
52+
term = "0.4.4"
53+
time = "0.1.34"
54+
toml = "0.4"
55+
url = "1.1.0"
5356
wait-timeout = "0.1.5"
54-
remove_dir_all = "0.2.0"
5557

5658
[target."cfg(windows)".dependencies]
5759
winapi = "0.2.8"

src/download/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ curl-backend = ["curl"]
1414
reqwest-backend = ["reqwest", "env_proxy", "lazy_static"]
1515

1616
[dependencies]
17-
error-chain = "0.10"
17+
error-chain = "0.11"
1818
url = "1.2"
1919
curl = { version = "0.4.6", optional = true }
2020
env_proxy = { version = "0.1.1", optional = true }
21-
lazy_static = { version = "0.1", optional = true }
21+
lazy_static = { version = "0.2", optional = true }
2222
reqwest = { version = "0.7.3", optional = true }
2323

2424
[dev-dependencies]

src/rustup-cli/self_update.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,8 +1377,8 @@ pub fn prepare_update() -> Result<Option<PathBuf>> {
13771377
let release_file = tempdir.path().join("release-stable.toml");
13781378
try!(utils::download_file(&release_file_url, &release_file, None, &|_| ()));
13791379
let release_toml_str = try!(utils::read_file("rustup release", &release_file));
1380-
let release_toml = try!(toml::Parser::new(&release_toml_str).parse()
1381-
.ok_or(Error::from("unable to parse rustup release file")));
1380+
let release_toml: toml::Value = try!(toml::from_str(&release_toml_str)
1381+
.map_err(|_| Error::from("unable to parse rustup release file")));
13821382
let schema = try!(release_toml.get("schema-version")
13831383
.ok_or(Error::from("no schema key in rustup release file")));
13841384
let schema = try!(schema.as_str()

src/rustup-dist/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ url = "1.1.0"
2020
tar = "0.4.0"
2121
flate2 = "0.2.9"
2222
xz2 = "0.1.3"
23-
tempdir = "0.3.4"
2423
walkdir = "1.0"
25-
toml = "0.1.27"
24+
toml = "0.4"
2625
sha2 = "0.6.0"
2726
remove_dir_all = "0.2"
2827
rustup-utils = { path = "../rustup-utils" }
29-
error-chain = "0.10"
28+
error-chain = "0.11"
3029

3130
[dev-dependencies]
3231
rustup-mock = { path = "../rustup-mock" }
32+
tempdir = "0.3.4"
3333

3434
[target."cfg(windows)".dependencies]
3535
winapi = "0.2.8"

src/rustup-dist/src/config.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub struct Config {
1414
}
1515

1616
impl Config {
17-
pub fn from_toml(mut table: toml::Table, path: &str) -> Result<Self> {
17+
pub fn from_toml(mut table: toml::value::Table, path: &str) -> Result<Self> {
1818
let version = try!(get_string(&mut table, "config_version", path));
1919
if !SUPPORTED_CONFIG_VERSIONS.contains(&&*version) {
2020
return Err(ErrorKind::UnsupportedVersion(version).into());
@@ -29,8 +29,8 @@ impl Config {
2929
components: components,
3030
})
3131
}
32-
pub fn to_toml(self) -> toml::Table {
33-
let mut result = toml::Table::new();
32+
pub fn to_toml(self) -> toml::value::Table {
33+
let mut result = toml::value::Table::new();
3434
result.insert("config_version".to_owned(),
3535
toml::Value::String(self.config_version));
3636
let components = Self::components_to_toml(self.components);
@@ -41,17 +41,15 @@ impl Config {
4141
}
4242

4343
pub fn parse(data: &str) -> Result<Self> {
44-
let mut parser = toml::Parser::new(data);
45-
let value = try!(parser.parse().ok_or_else(move || ErrorKind::Parsing(parser.errors)));
46-
44+
let value = toml::from_str(data).map_err(ErrorKind::Parsing)?;
4745
Self::from_toml(value, "")
4846
}
4947

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

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

5755
for (i, v) in arr.into_iter().enumerate() {
@@ -64,8 +62,8 @@ impl Config {
6462
Ok(result)
6563
}
6664

67-
fn components_to_toml(components: Vec<Component>) -> toml::Array {
68-
let mut result = toml::Array::new();
65+
fn components_to_toml(components: Vec<Component>) -> toml::value::Array {
66+
let mut result = toml::value::Array::new();
6967
for v in components {
7068
result.push(toml::Value::Table(v.to_toml()));
7169
}

src/rustup-dist/src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ error_chain! {
9292
}
9393
})
9494
}
95-
Parsing(e: Vec<toml::ParserError>) {
95+
Parsing(e: toml::de::Error) {
9696
description("error parsing manifest")
9797
}
9898
UnsupportedVersion(v: String) {

src/rustup-dist/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
extern crate regex;
44
extern crate itertools;
5-
extern crate tempdir;
65
extern crate walkdir;
76
extern crate toml;
87
extern crate flate2;

src/rustup-dist/src/manifest.rs

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,8 @@ pub struct Component {
6363

6464
impl Manifest {
6565
pub fn parse(data: &str) -> Result<Self> {
66-
let mut parser = toml::Parser::new(data);
67-
let value = try!(parser.parse().ok_or_else(move || ErrorKind::Parsing(parser.errors)));
68-
69-
let manifest = try!(Self::from_toml(value, ""));
66+
let value = toml::from_str(data).map_err(ErrorKind::Parsing)?;
67+
let manifest = Self::from_toml(value, "")?;
7068
try!(manifest.validate());
7169

7270
Ok(manifest)
@@ -75,7 +73,7 @@ impl Manifest {
7573
toml::Value::Table(self.to_toml()).to_string()
7674
}
7775

78-
pub fn from_toml(mut table: toml::Table, path: &str) -> Result<Self> {
76+
pub fn from_toml(mut table: toml::value::Table, path: &str) -> Result<Self> {
7977
let version = try!(get_string(&mut table, "manifest-version", path));
8078
if !SUPPORTED_MANIFEST_VERSIONS.contains(&&*version) {
8179
return Err(ErrorKind::UnsupportedVersion(version).into());
@@ -87,8 +85,8 @@ impl Manifest {
8785
renames: try!(Self::table_to_renames(table, path)),
8886
})
8987
}
90-
pub fn to_toml(self) -> toml::Table {
91-
let mut result = toml::Table::new();
88+
pub fn to_toml(self) -> toml::value::Table {
89+
let mut result = toml::value::Table::new();
9290

9391
result.insert("date".to_owned(), toml::Value::String(self.date));
9492
result.insert("manifest-version".to_owned(),
@@ -103,7 +101,7 @@ impl Manifest {
103101
result
104102
}
105103

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

@@ -115,15 +113,15 @@ impl Manifest {
115113

116114
Ok(result)
117115
}
118-
fn packages_to_table(packages: HashMap<String, Package>) -> toml::Table {
119-
let mut result = toml::Table::new();
116+
fn packages_to_table(packages: HashMap<String, Package>) -> toml::value::Table {
117+
let mut result = toml::value::Table::new();
120118
for (k, v) in packages {
121119
result.insert(k, toml::Value::Table(v.to_toml()));
122120
}
123121
result
124122
}
125123

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

@@ -135,10 +133,10 @@ impl Manifest {
135133

136134
Ok(result)
137135
}
138-
fn renames_to_table(renames: HashMap<String, String>) -> toml::Table {
139-
let mut result = toml::Table::new();
136+
fn renames_to_table(renames: HashMap<String, String>) -> toml::value::Table {
137+
let mut result = toml::value::Table::new();
140138
for (from, to) in renames {
141-
let mut table = toml::Table::new();
139+
let mut table = toml::value::Table::new();
142140
table.insert("to".to_owned(), toml::Value::String(to));
143141
result.insert(from, toml::Value::Table(table));
144142
}
@@ -190,14 +188,14 @@ impl Manifest {
190188
}
191189

192190
impl Package {
193-
pub fn from_toml(mut table: toml::Table, path: &str) -> Result<Self> {
191+
pub fn from_toml(mut table: toml::value::Table, path: &str) -> Result<Self> {
194192
Ok(Package {
195193
version: try!(get_string(&mut table, "version", path)),
196194
targets: try!(Self::toml_to_targets(table, path)),
197195
})
198196
}
199-
pub fn to_toml(self) -> toml::Table {
200-
let mut result = toml::Table::new();
197+
pub fn to_toml(self) -> toml::value::Table {
198+
let mut result = toml::value::Table::new();
201199

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

@@ -207,7 +205,7 @@ impl Package {
207205
result
208206
}
209207

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

213211
if let Some(toml::Value::Table(t)) = target_table.remove("*") {
@@ -222,8 +220,8 @@ impl Package {
222220
Ok(PackageTargets::Targeted(result))
223221
}
224222
}
225-
fn targets_to_toml(targets: PackageTargets) -> toml::Table {
226-
let mut result = toml::Table::new();
223+
fn targets_to_toml(targets: PackageTargets) -> toml::value::Table {
224+
let mut result = toml::value::Table::new();
227225
match targets {
228226
PackageTargets::Wildcard(tpkg) => {
229227
result.insert("*".to_owned(), toml::Value::Table(tpkg.to_toml()));
@@ -268,7 +266,7 @@ impl PackageTargets {
268266
}
269267

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

@@ -293,10 +291,10 @@ impl TargetedPackage {
293291
})
294292
}
295293
}
296-
pub fn to_toml(self) -> toml::Table {
294+
pub fn to_toml(self) -> toml::value::Table {
297295
let extensions = Self::components_to_toml(self.extensions);
298296
let components = Self::components_to_toml(self.components);
299-
let mut result = toml::Table::new();
297+
let mut result = toml::value::Table::new();
300298
if !extensions.is_empty() {
301299
result.insert("extensions".to_owned(), toml::Value::Array(extensions));
302300
}
@@ -321,7 +319,7 @@ impl TargetedPackage {
321319
self.bins.is_some()
322320
}
323321

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

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

334332
Ok(result)
335333
}
336-
fn components_to_toml(components: Vec<Component>) -> toml::Array {
337-
let mut result = toml::Array::new();
334+
fn components_to_toml(components: Vec<Component>) -> toml::value::Array {
335+
let mut result = toml::value::Array::new();
338336
for v in components {
339337
result.push(toml::Value::Table(v.to_toml()));
340338
}
@@ -343,7 +341,7 @@ impl TargetedPackage {
343341
}
344342

345343
impl Component {
346-
pub fn from_toml(mut table: toml::Table, path: &str) -> Result<Self> {
344+
pub fn from_toml(mut table: toml::value::Table, path: &str) -> Result<Self> {
347345
Ok(Component {
348346
pkg: try!(get_string(&mut table, "pkg", path)),
349347
target: try!(get_string(&mut table, "target", path).map(|s| {
@@ -355,8 +353,8 @@ impl Component {
355353
})),
356354
})
357355
}
358-
pub fn to_toml(self) -> toml::Table {
359-
let mut result = toml::Table::new();
356+
pub fn to_toml(self) -> toml::value::Table {
357+
let mut result = toml::value::Table::new();
360358
result.insert("target".to_owned(), toml::Value::String(
361359
self.target.map(|t| t.to_string()).unwrap_or_else(||"*".to_owned())
362360
));

src/rustup-mock/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,13 @@ repository = "https://github.com/rust-lang-nursery/rustup.rs"
1111

1212
[dependencies]
1313
url = "1.1.0"
14-
scopeguard = "0.3.0"
1514
lazy_static = "0.2.0"
1615
walkdir = "1.0.0"
1716
flate2 = "0.2.9"
1817
xz2 = "0.1.3"
1918
tempdir = "0.3.4"
20-
itertools = "0.6"
2119
tar = "0.4.0"
22-
toml = "0.1.27"
23-
rustup-utils = { path = "../rustup-utils" }
20+
toml = "0.4"
2421
sha2 = "0.6.0"
2522
wait-timeout = "0.1.3"
2623

0 commit comments

Comments
 (0)