@@ -269,7 +269,7 @@ fn ask_to_run(mut cmd: Command, ask: bool, text: &str) {
269269/// `MIRI_SYSROOT`. Skipped if `MIRI_SYSROOT` is already set, in which case we expect the user has
270270/// done all this already.
271271fn setup ( subcommand : MiriCommand ) {
272- if std:: env:: var ( "MIRI_SYSROOT" ) . is_ok ( ) {
272+ if std:: env:: var_os ( "MIRI_SYSROOT" ) . is_some ( ) {
273273 if subcommand == MiriCommand :: Setup {
274274 println ! ( "WARNING: MIRI_SYSROOT already set, not doing anything." )
275275 }
@@ -282,7 +282,7 @@ fn setup(subcommand: MiriCommand) {
282282
283283 // First, we need xargo.
284284 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 ( ) {
286286 // The user manually gave us a xargo binary; don't do anything automatically.
287287 show_error ( format ! ( "Your xargo is too old; please upgrade to the latest version" ) )
288288 }
@@ -292,9 +292,9 @@ fn setup(subcommand: MiriCommand) {
292292 }
293293
294294 // 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 => {
298298 // Check for `rust-src` rustup component.
299299 let sysroot = rustc ( )
300300 . args ( & [ "--print" , "sysroot" ] )
@@ -522,7 +522,7 @@ fn inside_cargo_rustc() {
522522 is_bin || is_test
523523 }
524524
525- let verbose = std:: env:: var ( "MIRI_VERBOSE" ) . is_ok ( ) ;
525+ let verbose = std:: env:: var_os ( "MIRI_VERBOSE" ) . is_some ( ) ;
526526 let target_crate = is_target_crate ( ) ;
527527
528528 // Figure out which arguments we need to pass.
@@ -531,6 +531,7 @@ fn inside_cargo_rustc() {
531531 // other args for target crates - that is, crates which are ultimately
532532 // going to get interpreted by Miri.
533533 if target_crate {
534+ // FIXME: breaks for non-UTF-8 sysroots (use `var_os` instead).
534535 let sysroot =
535536 std:: env:: var ( "MIRI_SYSROOT" ) . expect ( "The wrapper should have set MIRI_SYSROOT" ) ;
536537 args. push ( "--sysroot" . to_owned ( ) ) ;
@@ -545,6 +546,8 @@ fn inside_cargo_rustc() {
545546 // we want to interpret under Miri. We deserialize the user-provided arguments
546547 // from the special environment variable "MIRI_ARGS", and feed them
547548 // to the 'miri' binary.
549+ //
550+ // `env::var` is okay here, well-formed JSON is always UTF-8.
548551 let magic = std:: env:: var ( "MIRI_ARGS" ) . expect ( "missing MIRI_ARGS" ) ;
549552 let mut user_args: Vec < String > =
550553 serde_json:: from_str ( & magic) . expect ( "failed to deserialize MIRI_ARGS" ) ;
0 commit comments