Repository: rust-lang/rust
File: src/bootstrap/src/core/build_steps/test.rs (Rust)

Code before:
        let target = self.target;
        let stage = builder.top_stage;
        if stage == 0 {
            eprintln!("cargo-miri cannot be tested at stage 0");
            std::process::exit(1);
        }

        // This compiler runs on the host, we'll just use it for the target.
        let build_compiler = builder.compiler(stage, host);

        // Run `cargo miri test`.
        // This is just a smoke test (Miri's own CI invokes this in a bunch of different ways and ensures
        // that we get the desired output), but that is sufficient to make sure that the libtest harness
        // itself executes properly under Miri, and that all the logic in `cargo-miri` does not explode.
        let mut cargo = tool::prepare_tool_cargo(
            builder,
            build_compiler,
            Mode::ToolStd, // it's unclear what to use here, we're not building anything just doing a smoke test!
            target,
            Kind::MiriTest,
            "src/tools/miri/test-cargo-miri",
            SourceType::Submodule,
            &[],
        );

        // If we are testing stage 2+ cargo miri, make sure that it works with the in-tree cargo.
        if stage >= 2 {
            let built_cargo = builder
                .ensure(tool::Cargo::from_build_compiler(
                    // For stage 2 cargo miri, we want to use stage 1 cargo. So we need to build it
                    // with stage 0 rustc.
                    builder.compiler(stage - 2, builder.host_target),
                    target,
                ))
                .tool_path;
            cargo.env("CARGO", built_cargo);
        }

        // We're not using `prepare_cargo_test` so we have to do this ourselves.
        // (We're not using that as the test-cargo-miri crate is not known to bootstrap.)
        match builder.doc_tests {
            DocTests::Yes => {}
            DocTests::No => {
                cargo.args(["--lib", "--bins", "--examples", "--tests", "--benches"]);
            }
            DocTests::Only => {
                cargo.arg("--doc");
            }
        }
        cargo.arg("--").args(builder.config.test_args());


Review comment (suggestion):
```suggestion
        // If we are testing stage 2+ cargo miri, make sure that it works with the in-tree cargo.
        // We want to do this *somewhere* to ensure that Miri + nightly cargo actually works.
```

Code after:
        let target = self.target;
        let stage = builder.top_stage;
        if stage == 0 {
            eprintln!("cargo-miri cannot be tested at stage 0");
            std::process::exit(1);
        }

        // This compiler runs on the host, we'll just use it for the target.
        let build_compiler = builder.compiler(stage, host);

        // Run `cargo miri test`.
        // This is just a smoke test (Miri's own CI invokes this in a bunch of different ways and ensures
        // that we get the desired output), but that is sufficient to make sure that the libtest harness
        // itself executes properly under Miri, and that all the logic in `cargo-miri` does not explode.
        let mut cargo = tool::prepare_tool_cargo(
            builder,
            build_compiler,
            Mode::ToolStd, // it's unclear what to use here, we're not building anything just doing a smoke test!
            target,
            Kind::MiriTest,
            "src/tools/miri/test-cargo-miri",
            SourceType::Submodule,
            &[],
        );

        // If we are testing stage 2+ cargo miri, make sure that it works with the in-tree cargo.
        // We want to do this *somewhere* to ensure that Miri + nightly cargo actually works.
        if stage >= 2 {
            let built_cargo = builder
                .ensure(tool::Cargo::from_build_compiler(
                    // Build stage 1 cargo here, we don't need it to be built in any special way,
                    // just that it is built from in-tree sources.
                    builder.compiler(0, builder.host_target),
                    builder.host_target,
                ))
                .tool_path;
            cargo.env("CARGO", built_cargo);
        }

        // We're not using `prepare_cargo_test` so we have to do this ourselves.
        // (We're not using that as the test-cargo-miri crate is not known to bootstrap.)
        match builder.doc_tests {
            DocTests::Yes => {}
            DocTests::No => {
                cargo.args(["--lib", "--bins", "--examples", "--tests", "--benches"]);
            }
            DocTests::Only => {
                cargo.arg("--doc");
            }
        }
        cargo.arg("--").args(builder.config.test_args());