@@ -46,7 +46,11 @@ pub(crate) enum InstallError {
46
46
#[ fail( display = "Could not move tempdir into destination: {}" , _0) ]
47
47
Move ( #[ cause] io:: Error ) ,
48
48
#[ 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
+ } ,
50
54
}
51
55
52
56
#[ derive( Debug ) ]
@@ -122,7 +126,11 @@ impl Toolchain {
122
126
false
123
127
}
124
128
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 > {
126
134
debug ! ( "installing {}" , self ) ;
127
135
let tmpdir = TempDir :: new_in ( & dl_params. tmp_dir , & self . rustup_name ( ) )
128
136
. map_err ( InstallError :: TempDir ) ?;
@@ -141,9 +149,11 @@ impl Toolchain {
141
149
debug ! ( "installing (via link) {}" , self ) ;
142
150
143
151
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
+ ) ;
147
157
let stdout = cmd. output ( ) ?. stdout ;
148
158
let output = String :: from_utf8_lossy ( & stdout) ;
149
159
// the output should be the path, terminated by a newline
@@ -153,11 +163,13 @@ impl Toolchain {
153
163
path
154
164
} ;
155
165
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
+ ) ;
161
173
if cmd. status ( ) ?. success ( ) {
162
174
return Ok ( ( ) ) ;
163
175
} else {
@@ -209,11 +221,14 @@ impl Toolchain {
209
221
"{}/{}/{}.tar" ,
210
222
dl_params. url_prefix, location, rust_std_filename
211
223
) ,
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
+ ) ,
215
229
& tmpdir. path ( ) . join ( "lib" ) ,
216
- ) . map_err ( InstallError :: Download ) ?;
230
+ )
231
+ . map_err ( InstallError :: Download ) ?;
217
232
}
218
233
219
234
if dl_params. install_cargo {
@@ -224,7 +239,8 @@ impl Toolchain {
224
239
& format ! ( "{}/{}/{}.tar" , dl_params. url_prefix, location, filename, ) ,
225
240
Some ( & PathBuf :: from ( & filename) . join ( "cargo" ) ) ,
226
241
tmpdir. path ( ) ,
227
- ) . map_err ( InstallError :: Download ) ?;
242
+ )
243
+ . map_err ( InstallError :: Download ) ?;
228
244
}
229
245
230
246
if dl_params. install_src {
@@ -235,7 +251,8 @@ impl Toolchain {
235
251
& format ! ( "{}/{}/{}.tar" , dl_params. url_prefix, location, filename, ) ,
236
252
Some ( & PathBuf :: from ( & filename) . join ( "rust-src" ) ) ,
237
253
tmpdir. path ( ) ,
238
- ) . map_err ( InstallError :: Download ) ?;
254
+ )
255
+ . map_err ( InstallError :: Download ) ?;
239
256
}
240
257
241
258
fs:: rename ( tmpdir. into_path ( ) , dest) . map_err ( InstallError :: Move ) ?;
@@ -256,8 +273,9 @@ impl Toolchain {
256
273
let rustup_name = self . rustup_name ( ) ;
257
274
258
275
// 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
+ ) ;
261
279
262
280
let dir = dl_params. install_dir . join ( rustup_name) ;
263
281
fs:: remove_dir_all ( & dir) ?;
@@ -298,12 +316,14 @@ impl Toolchain {
298
316
let must_capture_output = cfg. output_processing_mode ( ) . must_process_stderr ( ) ;
299
317
let emit_output = cfg. args . emit_cargo_output ( ) || cfg. args . prompt ;
300
318
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
+ }
307
327
} ;
308
328
309
329
cmd. stdout ( default_stdio ( ) ) ;
@@ -414,7 +434,6 @@ impl DownloadParams {
414
434
}
415
435
}
416
436
417
-
418
437
#[ derive( Fail , Debug ) ]
419
438
pub ( crate ) enum ArchiveError {
420
439
#[ fail( display = "Failed to parse archive: {}" , _0) ]
@@ -445,7 +464,9 @@ pub(crate) fn download_progress(
445
464
if response. status ( ) == reqwest:: StatusCode :: NOT_FOUND {
446
465
return Err ( DownloadError :: NotFound ( url. to_string ( ) ) ) ;
447
466
}
448
- let response = response. error_for_status ( ) . map_err ( DownloadError :: Reqwest ) ?;
467
+ let response = response
468
+ . error_for_status ( )
469
+ . map_err ( DownloadError :: Reqwest ) ?;
449
470
450
471
let length = response
451
472
. headers ( )
@@ -488,7 +509,11 @@ pub(crate) fn download_tar_gz(
488
509
Ok ( ( ) )
489
510
}
490
511
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 > {
492
517
for entry in Archive :: new ( r) . entries ( ) . map_err ( ArchiveError :: Archive ) ? {
493
518
let mut entry = entry. map_err ( ArchiveError :: Archive ) ?;
494
519
let dest_path = {
0 commit comments