Skip to content

Commit 8da2c9e

Browse files
committed
fix adding default arguments
1 parent 5f42aa6 commit 8da2c9e

File tree

4 files changed

+6
-12
lines changed

4 files changed

+6
-12
lines changed

src/bin/cargo-miri.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ fn main() {
173173
.chain(Some(sys_root))
174174
.collect()
175175
};
176+
args.splice(0..0, miri::miri_default_args().iter().map(ToString::to_string));
176177

177178
// this check ensures that dependencies are built but not interpreted and the final crate is
178179
// interpreted but not built
@@ -186,7 +187,6 @@ fn main() {
186187
Command::new("rustc")
187188
};
188189

189-
miri::add_miri_default_args(&mut args);
190190
args.extend_from_slice(&["--cfg".to_owned(), r#"feature="cargo-miri""#.to_owned()]);
191191

192192
match command.args(&args).status() {

src/bin/miri-rustc-tests.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ fn main() {
156156
true
157157
}
158158
}).collect();
159+
args.splice(1..1, miri::miri_default_args().iter().map(ToString::to_string));
159160
// file to process
160161
args.push(path.display().to_string());
161162

@@ -165,8 +166,6 @@ fn main() {
165166
args.push(Path::new(&std::env::var("HOME").unwrap()).join(".xargo").join("HOST").display().to_string());
166167
}
167168

168-
miri::add_miri_default_args(&mut args);
169-
170169
// A threadsafe buffer for writing.
171170
#[derive(Default, Clone)]
172171
struct BufWriter(Arc<Mutex<Vec<u8>>>);

src/bin/miri.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ fn main() {
232232
args.push(sysroot_flag);
233233
args.push(find_sysroot());
234234
}
235-
// Finally, add the default flags all the way in the beginning.
236-
miri::add_miri_default_args(&mut args);
235+
// Finally, add the default flags all the way in the beginning, but after the binary name.
236+
args.splice(1..1, miri::miri_default_args().iter().map(ToString::to_string));
237237

238238
trace!("rustc arguments: {:?}", args);
239239
let result = rustc_driver::run(move || {

src/lib.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,11 @@ pub use crate::stacked_borrows::{Borrow, Stack, Stacks, Mut as MutBorrow, BorSta
5252

5353
/// Insert rustc arguments at the beginning of the argument listthat miri wants to be
5454
/// set per default, for maximal validation power.
55-
pub fn add_miri_default_args(args: &mut Vec<String>) {
55+
pub fn miri_default_args() -> &'static [&'static str] {
5656
// The flags here should be kept in sync with what bootstrap adds when `test-miri` is
5757
// set, which happens in `bootstrap/bin/rustc.rs` in the rustc sources; and also
5858
// kept in sync with `xargo/build.sh` in this repo and `appveyor.yml`.
59-
60-
// Inserting at index 1, after the binary name
61-
args.splice(1..1,
62-
["-Zalways-encode-mir", "-Zmir-emit-retag", "-Zmir-opt-level=0"]
63-
.iter().map(|s| s.to_string())
64-
);
59+
&["-Zalways-encode-mir", "-Zmir-emit-retag", "-Zmir-opt-level=0"]
6560
}
6661

6762
// Used by priroda

0 commit comments

Comments
 (0)