@@ -81,12 +81,13 @@ fn main() {
81
81
let config_res = config. configure (
82
82
0 , // verbose
83
83
quiet,
84
- & None , // color
84
+ None , // color
85
85
false , // frozen
86
86
false , // locked
87
87
matches. opt_present ( "offline" ) ,
88
88
& None , // target_dir
89
89
& [ ] , // unstable_flags
90
+ & [ ] , // cli_config
90
91
) ;
91
92
92
93
if let Err ( e) = config_res {
@@ -143,27 +144,27 @@ fn run(config: &cargo::Config, matches: &getopts::Matches) -> Result<()> {
143
144
. arg ( "-" )
144
145
. stdin ( Stdio :: piped ( ) )
145
146
. spawn ( )
146
- . map_err ( |e| failure :: err_msg ( format ! ( "could not spawn rustc: {}" , e) ) ) ?;
147
+ . map_err ( |e| anyhow :: Error :: msg ( format ! ( "could not spawn rustc: {}" , e) ) ) ?;
147
148
148
149
if let Some ( ref mut stdin) = child. stdin {
149
150
stdin. write_fmt ( format_args ! (
150
151
"#[allow(unused_extern_crates)] \
151
152
extern crate new;"
152
153
) ) ?;
153
154
} else {
154
- return Err ( failure :: err_msg (
155
+ return Err ( anyhow :: Error :: msg (
155
156
"could not pipe to rustc (wtf?)" . to_owned ( ) ,
156
157
) ) ;
157
158
}
158
159
159
160
let exit_status = child
160
161
. wait ( )
161
- . map_err ( |e| failure :: err_msg ( format ! ( "failed to wait for rustc: {}" , e) ) ) ?;
162
+ . map_err ( |e| anyhow :: Error :: msg ( format ! ( "failed to wait for rustc: {}" , e) ) ) ?;
162
163
163
164
return if exit_status. success ( ) {
164
165
Ok ( ( ) )
165
166
} else {
166
- Err ( failure :: err_msg ( "rustc-semver-public errored" . to_owned ( ) ) )
167
+ Err ( anyhow :: Error :: msg ( "rustc-semver-public errored" . to_owned ( ) ) )
167
168
} ;
168
169
}
169
170
@@ -239,7 +240,7 @@ fn run(config: &cargo::Config, matches: &getopts::Matches) -> Result<()> {
239
240
240
241
let mut child = child
241
242
. spawn ( )
242
- . map_err ( |e| failure :: err_msg ( format ! ( "could not spawn rustc: {}" , e) ) ) ?;
243
+ . map_err ( |e| anyhow :: Error :: msg ( format ! ( "could not spawn rustc: {}" , e) ) ) ?;
243
244
244
245
if let Some ( ref mut stdin) = child. stdin {
245
246
// The order of the `extern crate` declaration is important here: it will later
@@ -251,19 +252,19 @@ fn run(config: &cargo::Config, matches: &getopts::Matches) -> Result<()> {
251
252
extern crate new;"
252
253
) ) ?;
253
254
} else {
254
- return Err ( failure :: err_msg (
255
+ return Err ( anyhow :: Error :: msg (
255
256
"could not pipe to rustc (wtf?)" . to_owned ( ) ,
256
257
) ) ;
257
258
}
258
259
259
260
let exit_status = child
260
261
. wait ( )
261
- . map_err ( |e| failure :: err_msg ( format ! ( "failed to wait for rustc: {}" , e) ) ) ?;
262
+ . map_err ( |e| anyhow :: Error :: msg ( format ! ( "failed to wait for rustc: {}" , e) ) ) ?;
262
263
263
264
if exit_status. success ( ) {
264
265
Ok ( ( ) )
265
266
} else {
266
- Err ( failure :: err_msg ( "rustc-semverver errored" . to_owned ( ) ) )
267
+ Err ( anyhow :: Error :: msg ( "rustc-semverver errored" . to_owned ( ) ) )
267
268
}
268
269
}
269
270
@@ -353,21 +354,21 @@ mod cli {
353
354
}
354
355
355
356
/// Validate CLI arguments
356
- pub fn validate_args ( matches : & getopts:: Matches ) -> Result < ( ) , failure :: Error > {
357
+ pub fn validate_args ( matches : & getopts:: Matches ) -> Result < ( ) , anyhow :: Error > {
357
358
if ( matches. opt_present ( "s" ) && matches. opt_present ( "S" ) )
358
359
|| matches. opt_count ( "s" ) > 1
359
360
|| matches. opt_count ( "S" ) > 1
360
361
{
361
362
let msg = "at most one of `-s,--stable-path` and `-S,--stable-pkg` allowed" ;
362
- return Err ( failure :: err_msg ( msg. to_owned ( ) ) ) ;
363
+ return Err ( anyhow :: Error :: msg ( msg. to_owned ( ) ) ) ;
363
364
}
364
365
365
366
if ( matches. opt_present ( "c" ) && matches. opt_present ( "C" ) )
366
367
|| matches. opt_count ( "c" ) > 1
367
368
|| matches. opt_count ( "C" ) > 1
368
369
{
369
370
let msg = "at most one of `-c,--current-path` and `-C,--current-pkg` allowed" ;
370
- return Err ( failure :: err_msg ( msg. to_owned ( ) ) ) ;
371
+ return Err ( anyhow :: Error :: msg ( msg. to_owned ( ) ) ) ;
371
372
}
372
373
373
374
Ok ( ( ) )
@@ -386,7 +387,7 @@ mod cli {
386
387
}
387
388
388
389
/// Exit with error `e`.
389
- pub fn exit_with_error ( config : & cargo:: Config , e : failure :: Error ) -> ! {
390
+ pub fn exit_with_error ( config : & cargo:: Config , e : anyhow :: Error ) -> ! {
390
391
config
391
392
. shell ( )
392
393
. set_verbosity ( cargo:: core:: shell:: Verbosity :: Normal ) ;
@@ -406,7 +407,7 @@ impl<'a> PackageNameAndVersion<'a> {
406
407
/// Parses the string "name:version" into `Self`
407
408
pub fn parse ( s : & ' a str ) -> Result < Self > {
408
409
let err = || {
409
- failure :: err_msg ( format ! (
410
+ anyhow :: Error :: msg ( format ! (
410
411
"spec has to be of form `name:version` but is `{}`" ,
411
412
s
412
413
) )
@@ -536,7 +537,7 @@ impl<'a> WorkInfo<'a> {
536
537
}
537
538
}
538
539
539
- Err ( failure :: err_msg ( "lost build artifact" . to_owned ( ) ) )
540
+ Err ( anyhow :: Error :: msg ( "lost build artifact" . to_owned ( ) ) )
540
541
}
541
542
}
542
543
@@ -552,7 +553,7 @@ pub fn find_on_crates_io(crate_name: &str) -> Result<crates_io::Crate> {
552
553
registry
553
554
. search ( crate_name, 1 )
554
555
. map_err ( |e| {
555
- failure :: err_msg ( format ! (
556
+ anyhow :: Error :: msg ( format ! (
556
557
"failed to retrieve search results from the registry: {}" ,
557
558
e
558
559
) )
@@ -562,7 +563,7 @@ pub fn find_on_crates_io(crate_name: &str) -> Result<crates_io::Crate> {
562
563
. drain ( ..)
563
564
. find ( |krate| krate. name == crate_name)
564
565
. ok_or_else ( || {
565
- failure :: err_msg ( format ! ( "failed to find a matching crate `{}`" , crate_name) )
566
+ anyhow :: Error :: msg ( format ! ( "failed to find a matching crate `{}`" , crate_name) )
566
567
} )
567
568
} )
568
569
}
0 commit comments