Skip to content

Commit cef9a0e

Browse files
committed
fmt toolchains.rs
1 parent 89725a4 commit cef9a0e

File tree

1 file changed

+52
-27
lines changed

1 file changed

+52
-27
lines changed

src/toolchains.rs

Lines changed: 52 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ pub(crate) enum InstallError {
4646
#[fail(display = "Could not move tempdir into destination: {}", _0)]
4747
Move(#[cause] io::Error),
4848
#[fail(display = "Could not run subcommand {}: {}", command, cause)]
49-
Subcommand { command: String, #[cause] cause: io::Error }
49+
Subcommand {
50+
command: String,
51+
#[cause]
52+
cause: io::Error,
53+
},
5054
}
5155

5256
#[derive(Debug)]
@@ -122,7 +126,11 @@ impl Toolchain {
122126
false
123127
}
124128

125-
pub(crate) fn install(&self, client: &Client, dl_params: &DownloadParams) -> Result<(), InstallError> {
129+
pub(crate) fn install(
130+
&self,
131+
client: &Client,
132+
dl_params: &DownloadParams,
133+
) -> Result<(), InstallError> {
126134
debug!("installing {}", self);
127135
let tmpdir = TempDir::new_in(&dl_params.tmp_dir, &self.rustup_name())
128136
.map_err(InstallError::TempDir)?;
@@ -141,9 +149,11 @@ impl Toolchain {
141149
debug!("installing (via link) {}", self);
142150

143151
let nightly_path: String = {
144-
let cmd = CommandTemplate::new(["rustc", "--print", "sysroot"]
145-
.iter()
146-
.map(|s| s.to_string()));
152+
let cmd = CommandTemplate::new(
153+
["rustc", "--print", "sysroot"]
154+
.iter()
155+
.map(|s| s.to_string()),
156+
);
147157
let stdout = cmd.output()?.stdout;
148158
let output = String::from_utf8_lossy(&stdout);
149159
// the output should be the path, terminated by a newline
@@ -153,11 +163,13 @@ impl Toolchain {
153163
path
154164
};
155165

156-
let cmd = CommandTemplate::new(["rustup", "toolchain", "link"]
157-
.iter()
158-
.map(|s| s.to_string())
159-
.chain(iter::once(self.rustup_name()))
160-
.chain(iter::once(nightly_path)));
166+
let cmd = CommandTemplate::new(
167+
["rustup", "toolchain", "link"]
168+
.iter()
169+
.map(|s| s.to_string())
170+
.chain(iter::once(self.rustup_name()))
171+
.chain(iter::once(nightly_path)),
172+
);
161173
if cmd.status()?.success() {
162174
return Ok(());
163175
} else {
@@ -209,11 +221,14 @@ impl Toolchain {
209221
"{}/{}/{}.tar",
210222
dl_params.url_prefix, location, rust_std_filename
211223
),
212-
Some(&PathBuf::from(&rust_std_filename)
213-
.join(format!("rust-std-{}", target))
214-
.join("lib")),
224+
Some(
225+
&PathBuf::from(&rust_std_filename)
226+
.join(format!("rust-std-{}", target))
227+
.join("lib"),
228+
),
215229
&tmpdir.path().join("lib"),
216-
).map_err(InstallError::Download)?;
230+
)
231+
.map_err(InstallError::Download)?;
217232
}
218233

219234
if dl_params.install_cargo {
@@ -224,7 +239,8 @@ impl Toolchain {
224239
&format!("{}/{}/{}.tar", dl_params.url_prefix, location, filename,),
225240
Some(&PathBuf::from(&filename).join("cargo")),
226241
tmpdir.path(),
227-
).map_err(InstallError::Download)?;
242+
)
243+
.map_err(InstallError::Download)?;
228244
}
229245

230246
if dl_params.install_src {
@@ -235,7 +251,8 @@ impl Toolchain {
235251
&format!("{}/{}/{}.tar", dl_params.url_prefix, location, filename,),
236252
Some(&PathBuf::from(&filename).join("rust-src")),
237253
tmpdir.path(),
238-
).map_err(InstallError::Download)?;
254+
)
255+
.map_err(InstallError::Download)?;
239256
}
240257

241258
fs::rename(tmpdir.into_path(), dest).map_err(InstallError::Move)?;
@@ -256,8 +273,9 @@ impl Toolchain {
256273
let rustup_name = self.rustup_name();
257274

258275
// Guard against destroying directories that this tool didn't create.
259-
assert!(rustup_name.starts_with("bisector-nightly") ||
260-
rustup_name.starts_with("bisector-ci"));
276+
assert!(
277+
rustup_name.starts_with("bisector-nightly") || rustup_name.starts_with("bisector-ci")
278+
);
261279

262280
let dir = dl_params.install_dir.join(rustup_name);
263281
fs::remove_dir_all(&dir)?;
@@ -298,12 +316,14 @@ impl Toolchain {
298316
let must_capture_output = cfg.output_processing_mode().must_process_stderr();
299317
let emit_output = cfg.args.emit_cargo_output() || cfg.args.prompt;
300318

301-
let default_stdio = || if must_capture_output {
302-
Stdio::piped()
303-
} else if emit_output {
304-
Stdio::inherit()
305-
} else {
306-
Stdio::null()
319+
let default_stdio = || {
320+
if must_capture_output {
321+
Stdio::piped()
322+
} else if emit_output {
323+
Stdio::inherit()
324+
} else {
325+
Stdio::null()
326+
}
307327
};
308328

309329
cmd.stdout(default_stdio());
@@ -414,7 +434,6 @@ impl DownloadParams {
414434
}
415435
}
416436

417-
418437
#[derive(Fail, Debug)]
419438
pub(crate) enum ArchiveError {
420439
#[fail(display = "Failed to parse archive: {}", _0)]
@@ -445,7 +464,9 @@ pub(crate) fn download_progress(
445464
if response.status() == reqwest::StatusCode::NOT_FOUND {
446465
return Err(DownloadError::NotFound(url.to_string()));
447466
}
448-
let response = response.error_for_status().map_err(DownloadError::Reqwest)?;
467+
let response = response
468+
.error_for_status()
469+
.map_err(DownloadError::Reqwest)?;
449470

450471
let length = response
451472
.headers()
@@ -488,7 +509,11 @@ pub(crate) fn download_tar_gz(
488509
Ok(())
489510
}
490511

491-
pub(crate) fn unarchive<R: Read>(r: R, strip_prefix: Option<&Path>, dest: &Path) -> Result<(), ArchiveError> {
512+
pub(crate) fn unarchive<R: Read>(
513+
r: R,
514+
strip_prefix: Option<&Path>,
515+
dest: &Path,
516+
) -> Result<(), ArchiveError> {
492517
for entry in Archive::new(r).entries().map_err(ArchiveError::Archive)? {
493518
let mut entry = entry.map_err(ArchiveError::Archive)?;
494519
let dest_path = {

0 commit comments

Comments
 (0)