@@ -3,7 +3,6 @@ use std::io;
3
3
use std:: path:: { Path , PathBuf } ;
4
4
use std:: process:: { Command , Output } ;
5
5
use std:: str:: Utf8Error ;
6
- use std:: string:: FromUtf8Error ;
7
6
use tracing:: info;
8
7
9
8
pub enum CheckDiffError {
@@ -34,9 +33,9 @@ impl From<GitError> for CheckDiffError {
34
33
}
35
34
}
36
35
37
- impl From < FromUtf8Error > for CheckDiffError {
38
- fn from ( error : FromUtf8Error ) -> Self {
39
- CheckDiffError :: FailedUtf8 ( error. utf8_error ( ) )
36
+ impl From < Utf8Error > for CheckDiffError {
37
+ fn from ( error : Utf8Error ) -> Self {
38
+ CheckDiffError :: FailedUtf8 ( error)
40
39
}
41
40
}
42
41
@@ -87,8 +86,7 @@ impl RustfmtRunner {
87
86
) ) ;
88
87
} ;
89
88
90
- let binding = String :: from_utf8 ( command. stdout ) ?;
91
- let binary_version = binding. trim ( ) ;
89
+ let binary_version = std:: str:: from_utf8 ( & command. stdout ) ?. trim_end ( ) ;
92
90
return Ok ( binary_version. to_string ( ) ) ;
93
91
}
94
92
}
@@ -196,7 +194,7 @@ pub fn get_ld_lib_path() -> Result<String, CheckDiffError> {
196
194
return Err ( CheckDiffError :: FailedCommand ( "Error getting sysroot" ) ) ;
197
195
} ;
198
196
199
- let sysroot = String :: from_utf8 ( command. stdout ) ?;
197
+ let sysroot = std :: str :: from_utf8 ( & command. stdout ) ?. trim_end ( ) ;
200
198
201
199
let ld_lib_path = format ! ( "{}/lib" , sysroot. trim_end( ) ) ;
202
200
return Ok ( ld_lib_path) ;
@@ -209,9 +207,8 @@ pub fn get_cargo_version() -> Result<String, CheckDiffError> {
209
207
) ) ;
210
208
} ;
211
209
212
- let cargo_version = String :: from_utf8 ( command. stdout ) ?;
213
-
214
- return Ok ( cargo_version) ;
210
+ let cargo_version = std:: str:: from_utf8 ( & command. stdout ) ?. trim_end ( ) ;
211
+ return Ok ( cargo_version. to_string ( ) ) ;
215
212
}
216
213
217
214
/// Obtains the ld_lib path and then builds rustfmt from source
0 commit comments