@@ -123,31 +123,14 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
123
123
}
124
124
}
125
125
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
-
143
126
struct MiriBeRustCompilerCalls {
144
- mode : MiriBeRustcMode ,
127
+ target_crate : bool ,
145
128
}
146
129
147
130
impl rustc_driver:: Callbacks for MiriBeRustCompilerCalls {
148
131
#[ allow( rustc:: potential_query_instability) ] // rustc_codegen_ssa (where this code is copied from) also allows this lint
149
132
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 {
151
134
// Queries overridden here affect the data stored in `rmeta` files of dependencies,
152
135
// which will be used later in non-`MIRI_BE_RUSTC` mode.
153
136
config. override_queries = Some ( |_, local_providers| {
@@ -203,11 +186,9 @@ impl rustc_driver::Callbacks for MiriBeRustCompilerCalls {
203
186
queries : & ' tcx rustc_interface:: Queries < ' tcx > ,
204
187
) -> Compilation {
205
188
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 ( ( ) ) ;
211
192
} ) ;
212
193
Compilation :: Continue
213
194
}
@@ -383,18 +364,19 @@ fn main() {
383
364
rustc_driver:: install_ice_hook ( rustc_driver:: DEFAULT_BUG_REPORT_URL , |_| ( ) ) ;
384
365
rustc_driver:: init_rustc_env_logger ( & early_dcx) ;
385
366
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:?}" )
391
373
} ;
392
374
393
375
// We cannot use `rustc_driver::main` as we need to adjust the CLI arguments.
394
376
run_compiler (
395
377
args,
396
- mode . target_crate ( ) ,
397
- & mut MiriBeRustCompilerCalls { mode } ,
378
+ target_crate,
379
+ & mut MiriBeRustCompilerCalls { target_crate } ,
398
380
using_internal_features,
399
381
)
400
382
}
0 commit comments