Skip to content

Commit 61f57bb

Browse files
authored
Merge pull request #1585 from kinnison/kinnison/cargo-fmt
Reformat the entire codebase using `cargo fmt`
2 parents 31935e5 + 7a8c953 commit 61f57bb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1064
-1002
lines changed

src/download/src/lib.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ extern crate lazy_static;
1010
#[cfg(feature = "reqwest-backend")]
1111
extern crate reqwest;
1212

13-
use url::Url;
1413
use std::path::Path;
14+
use url::Url;
1515

1616
mod errors;
1717
pub use crate::errors::*;
@@ -122,7 +122,7 @@ pub fn download_to_path_with_backend(
122122

123123
Ok(())
124124
}()
125-
.map_err(|e| {
125+
.map_err(|e| {
126126
// TODO is there any point clearing up here? What kind of errors will leave us with an unusable partial?
127127
e
128128
})
@@ -136,12 +136,12 @@ pub mod curl {
136136
extern crate curl;
137137

138138
use self::curl::easy::Easy;
139+
use super::Event;
139140
use crate::errors::*;
140141
use std::cell::RefCell;
141142
use std::str;
142143
use std::time::Duration;
143144
use url::Url;
144-
use super::Event;
145145

146146
pub fn download(url: &Url, resume_from: u64, callback: &Fn(Event) -> Result<()>) -> Result<()> {
147147
// Fetch either a cached libcurl handle (which will preserve open
@@ -254,12 +254,12 @@ pub mod curl {
254254
pub mod reqwest_be {
255255
extern crate env_proxy;
256256

257+
use super::Event;
258+
use crate::errors::*;
259+
use reqwest::{header, Client, Proxy, Response};
257260
use std::io;
258261
use std::time::Duration;
259-
use crate::errors::*;
260262
use url::Url;
261-
use super::Event;
262-
use reqwest::{header, Client, Proxy, Response};
263263

264264
pub fn download(url: &Url, resume_from: u64, callback: &Fn(Event) -> Result<()>) -> Result<()> {
265265
// Short-circuit reqwest for the "file:" URL scheme
@@ -339,7 +339,8 @@ pub mod reqwest_be {
339339

340340
// The file scheme is mostly for use by tests to mock the dist server
341341
if url.scheme() == "file" {
342-
let src = url.to_file_path()
342+
let src = url
343+
.to_file_path()
343344
.map_err(|_| Error::from(format!("bogus file url: '{}'", url)))?;
344345
if !src.is_file() {
345346
// Because some of rustup's logic depends on checking
@@ -372,9 +373,9 @@ pub mod reqwest_be {
372373
#[cfg(not(feature = "curl-backend"))]
373374
pub mod curl {
374375

376+
use super::Event;
375377
use errors::*;
376378
use url::Url;
377-
use super::Event;
378379

379380
pub fn download(
380381
_url: &Url,
@@ -388,9 +389,9 @@ pub mod curl {
388389
#[cfg(not(feature = "reqwest-backend"))]
389390
pub mod reqwest_be {
390391

392+
use super::Event;
391393
use errors::*;
392394
use url::Url;
393-
use super::Event;
394395

395396
pub fn download(
396397
_url: &Url,

src/download/tests/download-curl-resume.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,17 @@ fn callback_gets_all_data_as_if_the_download_happened_all_at_once() {
5959
assert!(flag.is_none());
6060
*flag = Some(len);
6161
}
62-
Event::DownloadDataReceived(data) => for b in data.iter() {
63-
received_in_callback.lock().unwrap().push(b.clone());
64-
},
62+
Event::DownloadDataReceived(data) => {
63+
for b in data.iter() {
64+
received_in_callback.lock().unwrap().push(b.clone());
65+
}
66+
}
6567
}
6668

6769
Ok(())
6870
}),
69-
).expect("Test download failed");
71+
)
72+
.expect("Test download failed");
7073

7174
assert!(*callback_partial.lock().unwrap());
7275
assert_eq!(*callback_len.lock().unwrap(), Some(5));

src/download/tests/download-reqwest-resume.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,17 @@ fn callback_gets_all_data_as_if_the_download_happened_all_at_once() {
5959
assert!(flag.is_none());
6060
*flag = Some(len);
6161
}
62-
Event::DownloadDataReceived(data) => for b in data.iter() {
63-
received_in_callback.lock().unwrap().push(b.clone());
64-
},
62+
Event::DownloadDataReceived(data) => {
63+
for b in data.iter() {
64+
received_in_callback.lock().unwrap().push(b.clone());
65+
}
66+
}
6567
}
6668

6769
Ok(())
6870
}),
69-
).expect("Test download failed");
71+
)
72+
.expect("Test download failed");
7073

7174
assert!(*callback_partial.lock().unwrap());
7275
assert_eq!(*callback_len.lock().unwrap(), Some(5));

src/rustup-cli/common.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
//! Just a dumping ground for cli stuff
22
3-
use rustup::{self, Cfg, Notification, Toolchain, UpdateStatus};
4-
use rustup::telemetry_analysis::TelemetryAnalysis;
53
use crate::errors::*;
6-
use rustup_utils::utils;
7-
use rustup_utils::notify::NotificationLevel;
84
use crate::self_update;
5+
use crate::term2;
6+
use rustup::telemetry_analysis::TelemetryAnalysis;
7+
use rustup::{self, Cfg, Notification, Toolchain, UpdateStatus};
8+
use rustup_utils::notify::NotificationLevel;
9+
use rustup_utils::utils;
10+
use std;
911
use std::io::{BufRead, BufReader, Write};
10-
use std::process::{Command, Stdio};
1112
use std::path::Path;
12-
use std::{cmp, iter};
13+
use std::process::{Command, Stdio};
1314
use std::sync::Arc;
1415
use std::time::Duration;
15-
use std;
16-
use crate::term2;
16+
use std::{cmp, iter};
1717
use wait_timeout::ChildExt;
1818

1919
pub fn confirm(question: &str, default: bool) -> Result<bool> {
@@ -178,7 +178,8 @@ fn show_channel_updates(
178178
let mut t = term2::stdout();
179179

180180
let data: Vec<_> = data.collect();
181-
let max_width = data.iter()
181+
let max_width = data
182+
.iter()
182183
.fold(0, |a, &(_, _, width, _, _)| cmp::max(a, width));
183184

184185
for (name, banner, width, color, version) in data {
@@ -365,11 +366,8 @@ pub fn list_overrides(cfg: &Cfg) -> Result<()> {
365366
}
366367
println!(
367368
"{:<40}\t{:<20}",
368-
utils::format_path_for_display(&k) + if dir_exists {
369-
""
370-
} else {
371-
" (not a directory)"
372-
},
369+
utils::format_path_for_display(&k)
370+
+ if dir_exists { "" } else { " (not a directory)" },
373371
v
374372
)
375373
}

src/rustup-cli/download_tracker.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
use rustup::Notification;
2+
use rustup_dist::Notification as In;
3+
use rustup_utils::tty;
4+
use rustup_utils::Notification as Un;
15
use std::collections::VecDeque;
26
use std::fmt;
37
use term;
48
use time::precise_time_s;
5-
use rustup::Notification;
6-
use rustup_dist::Notification as In;
7-
use rustup_utils::Notification as Un;
8-
use rustup_utils::tty;
99

1010
/// Keep track of this many past download amounts
1111
const DOWNLOAD_TRACK_COUNT: usize = 5;
@@ -123,7 +123,8 @@ impl DownloadTracker {
123123
/// Display the tracked download information to the terminal.
124124
fn display(&mut self) {
125125
let total_h = HumanReadable(self.total_downloaded as f64);
126-
let sum = self.downloaded_last_few_secs
126+
let sum = self
127+
.downloaded_last_few_secs
127128
.iter()
128129
.fold(0., |a, &v| a + v as f64);
129130
let len = self.downloaded_last_few_secs.len();

src/rustup-cli/job.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ mod imp {
4444
use self::winapi::um::handleapi::*;
4545
use self::winapi::um::jobapi2::*;
4646
use self::winapi::um::processthreadsapi::*;
47-
use self::winapi::um::winnt::*;
4847
use self::winapi::um::winnt::HANDLE;
48+
use self::winapi::um::winnt::*;
4949

5050
pub struct Setup {
5151
job: Handle,

src/rustup-cli/main.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ extern crate winreg;
4646
mod log;
4747
mod common;
4848
mod download_tracker;
49+
mod errors;
50+
mod help;
51+
mod job;
4952
mod proxy_mode;
50-
mod setup_mode;
5153
mod rustup_mode;
5254
mod self_update;
53-
mod job;
55+
mod setup_mode;
5456
mod term2;
55-
mod errors;
56-
mod help;
5757

58+
use crate::errors::*;
59+
use rustup::env_var::RUST_RECURSION_COUNT_MAX;
60+
use rustup_dist::dist::TargetTriple;
5861
use std::alloc::System;
5962
use std::env;
6063
use std::path::PathBuf;
61-
use crate::errors::*;
62-
use rustup_dist::dist::TargetTriple;
63-
use rustup::env_var::RUST_RECURSION_COUNT_MAX;
6464

6565
// Always use the system allocator, to reduce binary size.
6666
#[global_allocator]
@@ -83,14 +83,16 @@ fn run_rustup() -> Result<()> {
8383

8484
// The name of arg0 determines how the program is going to behave
8585
let arg0 = env::args().next().map(PathBuf::from);
86-
let name = arg0.as_ref()
86+
let name = arg0
87+
.as_ref()
8788
.and_then(|a| a.file_stem())
8889
.and_then(|a| a.to_str());
8990

9091
match name {
9192
Some("rustup") => rustup_mode::main(),
9293
Some(n)
93-
if n.starts_with("multirust-setup") || n.starts_with("rustup-setup")
94+
if n.starts_with("multirust-setup")
95+
|| n.starts_with("rustup-setup")
9496
|| n.starts_with("rustup-init") =>
9597
{
9698
// NB: The above check is only for the prefix of the file
@@ -171,8 +173,8 @@ fn make_environment_compatible() {
171173
// REG_SZ type, when it should be REG_EXPAND_SZ. Silently fix it.
172174
#[cfg(windows)]
173175
fn fix_windows_reg_key() {
174-
use winreg::RegKey;
175176
use winreg::enums::{RegType, HKEY_CURRENT_USER, KEY_READ, KEY_WRITE};
177+
use winreg::RegKey;
176178

177179
let root = RegKey::predef(HKEY_CURRENT_USER);
178180
let env = root.open_subkey_with_flags("Environment", KEY_READ | KEY_WRITE);

src/rustup-cli/proxy_mode.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use crate::common::set_globals;
2-
use rustup::Cfg;
32
use crate::errors::*;
4-
use rustup_utils::utils::{self, ExitCode};
3+
use crate::job;
54
use rustup::command::run_command_for_dir;
5+
use rustup::Cfg;
6+
use rustup_utils::utils::{self, ExitCode};
67
use std::env;
78
use std::ffi::OsString;
89
use std::path::PathBuf;
910
use std::process;
10-
use crate::job;
1111

1212
pub fn main() -> Result<()> {
1313
crate::self_update::cleanup_self_updater()?;
@@ -18,7 +18,8 @@ pub fn main() -> Result<()> {
1818
let mut args = env::args();
1919

2020
let arg0 = args.next().map(PathBuf::from);
21-
let arg0 = arg0.as_ref()
21+
let arg0 = arg0
22+
.as_ref()
2223
.and_then(|a| a.file_name())
2324
.and_then(|a| a.to_str());
2425
let ref arg0 = arg0.ok_or(ErrorKind::NoExeName)?;
@@ -48,7 +49,12 @@ pub fn main() -> Result<()> {
4849
process::exit(c)
4950
}
5051

51-
fn direct_proxy(cfg: &Cfg, arg0: &str, toolchain: Option<&str>, args: &[OsString]) -> Result<ExitCode> {
52+
fn direct_proxy(
53+
cfg: &Cfg,
54+
arg0: &str,
55+
toolchain: Option<&str>,
56+
args: &[OsString],
57+
) -> Result<ExitCode> {
5258
let cmd = match toolchain {
5359
None => cfg.create_command_for_dir(&utils::current_dir()?, arg0)?,
5460
Some(tc) => cfg.create_command_for_toolchain(tc, false, arg0)?,

0 commit comments

Comments
 (0)