@@ -269,7 +269,7 @@ fn ask_to_run(mut cmd: Command, ask: bool, text: &str) {
269
269
/// `MIRI_SYSROOT`. Skipped if `MIRI_SYSROOT` is already set, in which case we expect the user has
270
270
/// done all this already.
271
271
fn setup(subcommand: MiriCommand) {
272
- if std::env::var ("MIRI_SYSROOT").is_ok () {
272
+ if std::env::var_os ("MIRI_SYSROOT").is_some () {
273
273
if subcommand == MiriCommand::Setup {
274
274
println!("WARNING: MIRI_SYSROOT already set, not doing anything.")
275
275
}
@@ -282,7 +282,7 @@ fn setup(subcommand: MiriCommand) {
282
282
283
283
// First, we need xargo.
284
284
if xargo_version().map_or(true, |v| v < XARGO_MIN_VERSION) {
285
- if std::env::var ("XARGO_CHECK").is_ok () {
285
+ if std::env::var_os ("XARGO_CHECK").is_some () {
286
286
// The user manually gave us a xargo binary; don't do anything automatically.
287
287
show_error(format!("Your xargo is too old; please upgrade to the latest version"))
288
288
}
@@ -292,9 +292,9 @@ fn setup(subcommand: MiriCommand) {
292
292
}
293
293
294
294
// Determine where the rust sources are located. `XARGO_RUST_SRC` env var trumps everything.
295
- let rust_src = match std::env::var ("XARGO_RUST_SRC") {
296
- Ok (val) => PathBuf::from(val),
297
- Err(_) => {
295
+ let rust_src = match std::env::var_os ("XARGO_RUST_SRC") {
296
+ Some (val) => PathBuf::from(val),
297
+ None => {
298
298
// Check for `rust-src` rustup component.
299
299
let sysroot = rustc()
300
300
.args(&["--print", "sysroot"])
@@ -522,7 +522,7 @@ fn inside_cargo_rustc() {
522
522
is_bin || is_test
523
523
}
524
524
525
- let verbose = std::env::var ("MIRI_VERBOSE").is_ok ();
525
+ let verbose = std::env::var_os ("MIRI_VERBOSE").is_some ();
526
526
let target_crate = is_target_crate();
527
527
528
528
// Figure out which arguments we need to pass.
@@ -531,6 +531,7 @@ fn inside_cargo_rustc() {
531
531
// other args for target crates - that is, crates which are ultimately
532
532
// going to get interpreted by Miri.
533
533
if target_crate {
534
+ // FIXME: breaks for non-UTF-8 sysroots (use `var_os` instead).
534
535
let sysroot =
535
536
std::env::var("MIRI_SYSROOT").expect("The wrapper should have set MIRI_SYSROOT");
536
537
args.push("--sysroot".to_owned());
@@ -545,6 +546,8 @@ fn inside_cargo_rustc() {
545
546
// we want to interpret under Miri. We deserialize the user-provided arguments
546
547
// from the special environment variable "MIRI_ARGS", and feed them
547
548
// to the 'miri' binary.
549
+ //
550
+ // `env::var` is okay here, well-formed JSON is always UTF-8.
548
551
let magic = std::env::var("MIRI_ARGS").expect("missing MIRI_ARGS");
549
552
let mut user_args: Vec<String> =
550
553
serde_json::from_str(&magic).expect("failed to deserialize MIRI_ARGS");
0 commit comments