@@ -53,7 +53,7 @@ fn cargo_fix() -> Result<(), Error> {
53
53
// Override the rustc compiler as ourselves. That way whenever rustc would
54
54
// run we run instead and have an opportunity to inject fixes.
55
55
let me = env:: current_exe ( )
56
- . with_context ( |_| "failed to learn about path to current exe" ) ?;
56
+ . context ( "failed to learn about path to current exe" ) ?;
57
57
cmd. env ( "RUSTC" , & me)
58
58
. env ( "__CARGO_FIX_NOW_RUSTC" , "1" ) ;
59
59
if let Some ( rustc) = env:: var_os ( "RUSTC" ) {
@@ -100,8 +100,7 @@ fn cargo_fix_rustc() -> Result<(), Error> {
100
100
// we applied, present a scary warning, and then move on.
101
101
let mut cmd = Command :: new ( & rustc) ;
102
102
cmd. args ( env:: args ( ) . skip ( 1 ) ) ;
103
- exit_with ( cmd. status ( ) . with_context ( |_| "failed to spawn rustc" ) ?) ;
104
-
103
+ exit_with ( cmd. status ( ) . context ( "failed to spawn rustc" ) ?) ;
105
104
}
106
105
107
106
fn rustfix_crate ( rustc : & Path , filename : & str ) -> Result < ( ) , Error > {
@@ -121,15 +120,16 @@ fn rustfix_crate(rustc: &Path, filename: &str) -> Result<(), Error> {
121
120
let mut cmd = Command :: new ( & rustc) ;
122
121
cmd. args ( env:: args ( ) . skip ( 1 ) ) ;
123
122
cmd. arg ( "--error-format=json" ) ;
124
- let context = format ! ( "failed to execute `{}`" , rustc . to_string_lossy ( ) ) ;
125
- let output = cmd . output ( ) . context ( context . clone ( ) ) ?;
123
+ let output = cmd . output ( )
124
+ . with_context ( |_| format ! ( "failed to execute `{}`" , rustc . display ( ) ) ) ?;
126
125
127
126
// Sift through the output of the compiler to look for JSON messages
128
127
// indicating fixes that we can apply. Note that we *do not* look at the
129
128
// exit status here, that's intentional! We want to apply fixes even if
130
129
// there are compiler errors.
131
130
let stderr = str:: from_utf8 ( & output. stderr )
132
- . map_err ( |_| format_err ! ( "failed to parse rustc stderr as utf-8" ) ) ?;
131
+ . context ( "failed to parse rustc stderr as utf-8" ) ?;
132
+
133
133
let suggestions = stderr. lines ( )
134
134
. filter ( |x| !x. is_empty ( ) )
135
135
0 commit comments