Skip to content

Commit 010d1d7

Browse files
committed
run full mono-item collection on all MIRI_BE_RUSTC builds
1 parent b00696b commit 010d1d7

File tree

2 files changed

+14
-32
lines changed

2 files changed

+14
-32
lines changed

cargo-miri/src/phases.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
364364
let out_filename = out_filename.expect("rustdoc must pass `-o`");
365365

366366
cmd.args(&args);
367-
cmd.env("MIRI_BE_RUSTC", "rustdoc");
367+
cmd.env("MIRI_BE_RUSTC", "target");
368368

369369
if verbose > 0 {
370370
eprintln!(

src/bin/miri.rs

+13-31
Original file line numberDiff line numberDiff line change
@@ -123,31 +123,14 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
123123
}
124124
}
125125

126-
#[derive(Copy, Clone, Debug, PartialEq)]
127-
enum MiriBeRustcMode {
128-
Target,
129-
Host,
130-
Rustdoc,
131-
}
132-
133-
impl MiriBeRustcMode {
134-
fn target_crate(self) -> bool {
135-
use MiriBeRustcMode::*;
136-
match self {
137-
Target | Rustdoc => true,
138-
Host => false,
139-
}
140-
}
141-
}
142-
143126
struct MiriBeRustCompilerCalls {
144-
mode: MiriBeRustcMode,
127+
target_crate: bool,
145128
}
146129

147130
impl rustc_driver::Callbacks for MiriBeRustCompilerCalls {
148131
#[allow(rustc::potential_query_instability)] // rustc_codegen_ssa (where this code is copied from) also allows this lint
149132
fn config(&mut self, config: &mut Config) {
150-
if config.opts.prints.is_empty() && self.mode == MiriBeRustcMode::Target {
133+
if config.opts.prints.is_empty() && self.target_crate {
151134
// Queries overridden here affect the data stored in `rmeta` files of dependencies,
152135
// which will be used later in non-`MIRI_BE_RUSTC` mode.
153136
config.override_queries = Some(|_, local_providers| {
@@ -203,11 +186,9 @@ impl rustc_driver::Callbacks for MiriBeRustCompilerCalls {
203186
queries: &'tcx rustc_interface::Queries<'tcx>,
204187
) -> Compilation {
205188
queries.global_ctxt().unwrap().enter(|tcx| {
206-
// Make sure compile_fail tests with post-monomorphization const-eval errors work as
207-
// intended in rustdoc mode.
208-
if self.mode == MiriBeRustcMode::Rustdoc {
209-
let _ = tcx.collect_and_partition_mono_items(());
210-
}
189+
// We are emulating regular rustc builds, which would perform post-mono const-eval.
190+
// So let's also do that here, even if we might be running with `--emit=metadata`.
191+
let _ = tcx.collect_and_partition_mono_items(());
211192
});
212193
Compilation::Continue
213194
}
@@ -383,18 +364,19 @@ fn main() {
383364
rustc_driver::install_ice_hook(rustc_driver::DEFAULT_BUG_REPORT_URL, |_| ());
384365
rustc_driver::init_rustc_env_logger(&early_dcx);
385366

386-
let mode = match crate_kind.to_str().unwrap_or_default() {
387-
"target" => MiriBeRustcMode::Target,
388-
"rustdoc" => MiriBeRustcMode::Rustdoc,
389-
"host" => MiriBeRustcMode::Host,
390-
_ => panic!("invalid `MIRI_BE_RUSTC` value: {crate_kind:?}"),
367+
let target_crate = if crate_kind == "target" {
368+
true
369+
} else if crate_kind == "host" {
370+
false
371+
} else {
372+
panic!("invalid `MIRI_BE_RUSTC` value: {crate_kind:?}")
391373
};
392374

393375
// We cannot use `rustc_driver::main` as we need to adjust the CLI arguments.
394376
run_compiler(
395377
args,
396-
mode.target_crate(),
397-
&mut MiriBeRustCompilerCalls { mode },
378+
target_crate,
379+
&mut MiriBeRustCompilerCalls { target_crate },
398380
using_internal_features,
399381
)
400382
}

0 commit comments

Comments
 (0)