@@ -119,26 +119,29 @@ fn list_targets() -> impl Iterator<Item=cargo_metadata::Target> {
119
119
package. targets . into_iter ( )
120
120
}
121
121
122
+ /// Returns the path to the `miri` binary
123
+ fn find_miri ( ) -> PathBuf {
124
+ let mut path = std:: env:: current_exe ( ) . expect ( "current executable path invalid" ) ;
125
+ path. set_file_name ( "miri" ) ;
126
+ path
127
+ }
128
+
122
129
/// Make sure that the `miri` and `rustc` binary are from the same sysroot.
123
130
/// This can be violated e.g. when miri is locally built and installed with a different
124
131
/// toolchain than what is used when `cargo miri` is run.
125
132
fn test_sysroot_consistency ( ) {
126
133
fn get_sysroot ( mut cmd : Command ) -> PathBuf {
127
134
let out = cmd. arg ( "--print" ) . arg ( "sysroot" )
128
135
. output ( ) . expect ( "Failed to run rustc to get sysroot info" ) ;
129
- assert ! ( out. status. success( ) , "Bad statuc code when getting sysroot info" ) ;
136
+ assert ! ( out. status. success( ) , "Bad status code when getting sysroot info" ) ;
130
137
let sysroot = out. stdout . lines ( ) . nth ( 0 )
131
138
. expect ( "didn't get at least one line for the sysroot" ) . unwrap ( ) ;
132
139
PathBuf :: from ( sysroot) . canonicalize ( )
133
140
. expect ( "Failed to canonicalize sysroot" )
134
141
}
135
142
136
143
let rustc_sysroot = get_sysroot ( Command :: new ( "rustc" ) ) ;
137
- let miri_sysroot = {
138
- let mut path = std:: env:: current_exe ( ) . expect ( "current executable path invalid" ) ;
139
- path. set_file_name ( "miri" ) ;
140
- get_sysroot ( Command :: new ( path) )
141
- } ;
144
+ let miri_sysroot = get_sysroot ( Command :: new ( find_miri ( ) ) ) ;
142
145
143
146
if rustc_sysroot != miri_sysroot {
144
147
show_error ( format ! (
@@ -451,9 +454,7 @@ fn inside_cargo_rustc() {
451
454
} ;
452
455
453
456
let mut command = if needs_miri {
454
- let mut path = std:: env:: current_exe ( ) . expect ( "current executable path invalid" ) ;
455
- path. set_file_name ( "miri" ) ;
456
- Command :: new ( path)
457
+ Command :: new ( find_miri ( ) )
457
458
} else {
458
459
Command :: new ( "rustc" )
459
460
} ;
0 commit comments