@@ -44,8 +44,6 @@ fn main() {
44
44
return ;
45
45
}
46
46
47
- let dep_path = std:: env:: current_dir ( ) . expect ( "current dir is not readable" ) . join ( "target" ) . join ( "debug" ) . join ( "deps" ) ;
48
-
49
47
if let Some ( "miri" ) = std:: env:: args ( ) . nth ( 1 ) . as_ref ( ) . map ( AsRef :: as_ref) {
50
48
// this arm is when `cargo miri` is called
51
49
@@ -84,13 +82,11 @@ fn main() {
84
82
let args = std:: env:: args ( ) . skip ( skip) ;
85
83
let kind = target. kind . get ( 0 ) . expect ( "badly formatted cargo metadata: target::kind is an empty array" ) ;
86
84
if test && kind == "test" {
87
- if let Err ( code) = process ( vec ! [ "--test" . to_string( ) , target. name] . into_iter ( ) . chain ( args) ,
88
- & dep_path) {
85
+ if let Err ( code) = process ( vec ! [ "--test" . to_string( ) , target. name] . into_iter ( ) . chain ( args) ) {
89
86
std:: process:: exit ( code) ;
90
87
}
91
88
} else if !test && kind == "bin" {
92
- if let Err ( code) = process ( vec ! [ "--bin" . to_string( ) , target. name] . into_iter ( ) . chain ( args) ,
93
- & dep_path) {
89
+ if let Err ( code) = process ( vec ! [ "--bin" . to_string( ) , target. name] . into_iter ( ) . chain ( args) ) {
94
90
std:: process:: exit ( code) ;
95
91
}
96
92
}
@@ -117,7 +113,7 @@ fn main() {
117
113
. expect ( "need to specify RUST_SYSROOT env var during miri compilation, or use rustup or multirust" )
118
114
} ;
119
115
120
- // this conditional check for the --sysroot flag is there so users can call `cargo-clippy ` directly
116
+ // this conditional check for the --sysroot flag is there so users can call `cargo-miri ` directly
121
117
// without having to pass --sysroot or anything
122
118
let mut args: Vec < String > = if std:: env:: args ( ) . any ( |s| s == "--sysroot" ) {
123
119
std:: env:: args ( ) . skip ( 1 ) . collect ( )
@@ -129,25 +125,29 @@ fn main() {
129
125
// interpreted but not built
130
126
let miri_enabled = std:: env:: args ( ) . any ( |s| s == "-Zno-trans" ) ;
131
127
132
- if miri_enabled {
133
- args. extend_from_slice ( & [ "--cfg" . to_owned ( ) , r#"feature="cargo-miri""# . to_owned ( ) ] ) ;
134
- }
128
+ let mut command = if miri_enabled {
129
+ let mut path = std:: env:: current_exe ( ) . expect ( "current executable path invalid" ) ;
130
+ path. set_file_name ( "miri" ) ;
131
+ Command :: new ( path)
132
+ } else {
133
+ Command :: new ( "rustc" )
134
+ } ;
135
135
136
- let mut path = std :: env :: current_exe ( ) . expect ( "current executable path invalid" ) ;
137
- path . set_file_name ( " miri") ;
136
+ args . extend_from_slice ( & [ "-Z" . to_owned ( ) , "always-encode-mir" . to_owned ( ) ] ) ;
137
+ args . extend_from_slice ( & [ "--cfg" . to_owned ( ) , r#"feature="cargo- miri""# . to_owned ( ) ] ) ;
138
138
139
- match Command :: new ( path ) . args ( & args) . status ( ) {
139
+ match command . args ( & args) . status ( ) {
140
140
Ok ( exit) => if !exit. success ( ) {
141
141
std:: process:: exit ( exit. code ( ) . unwrap_or ( 42 ) ) ;
142
142
} ,
143
- Err ( e) => panic ! ( "error during miri run: {:?}" , e) ,
143
+ Err ( ref e) if miri_enabled => panic ! ( "error during miri run: {:?}" , e) ,
144
+ Err ( ref e) => panic ! ( "error during rustc call: {:?}" , e) ,
144
145
}
145
146
}
146
147
}
147
148
148
- fn process < P , I > ( old_args : I , dep_path : P ) -> Result < ( ) , i32 >
149
- where P : AsRef < Path > ,
150
- I : Iterator < Item = String >
149
+ fn process < I > ( old_args : I ) -> Result < ( ) , i32 >
150
+ where I : Iterator < Item = String >
151
151
{
152
152
let mut args = vec ! [ "rustc" . to_owned( ) ] ;
153
153
@@ -159,8 +159,6 @@ fn process<P, I>(old_args: I, dep_path: P) -> Result<(), i32>
159
159
if !found_dashes {
160
160
args. push ( "--" . to_owned ( ) ) ;
161
161
}
162
- args. push ( "-L" . to_owned ( ) ) ;
163
- args. push ( dep_path. as_ref ( ) . to_string_lossy ( ) . into_owned ( ) ) ;
164
162
args. push ( "-Zno-trans" . to_owned ( ) ) ;
165
163
args. push ( "--cfg" . to_owned ( ) ) ;
166
164
args. push ( r#"feature="cargo-miri""# . to_owned ( ) ) ;
0 commit comments