@@ -31,9 +31,9 @@ use rustc_middle::{
31
31
query:: { ExternProviders , LocalCrate } ,
32
32
ty:: TyCtxt ,
33
33
} ;
34
- use rustc_session:: config :: OptLevel ;
35
-
36
- use rustc_session:: { config :: CrateType , search_paths:: PathKind , CtfeBacktrace } ;
34
+ use rustc_session:: { EarlyErrorHandler , CtfeBacktrace } ;
35
+ use rustc_session :: config :: { OptLevel , CrateType , ErrorOutputType } ;
36
+ use rustc_session:: search_paths:: PathKind ;
37
37
38
38
use miri:: { BacktraceStyle , BorrowTrackerMethod , ProvenanceMode , RetagFields } ;
39
39
@@ -59,15 +59,16 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
59
59
60
60
fn after_analysis < ' tcx > (
61
61
& mut self ,
62
+ handler : & EarlyErrorHandler ,
62
63
_: & rustc_interface:: interface:: Compiler ,
63
64
queries : & ' tcx rustc_interface:: Queries < ' tcx > ,
64
65
) -> Compilation {
65
66
queries. global_ctxt ( ) . unwrap ( ) . enter ( |tcx| {
66
67
if tcx. sess . compile_status ( ) . is_err ( ) {
67
68
tcx. sess . fatal ( "miri cannot be run on programs that fail compilation" ) ;
68
69
}
69
-
70
- init_late_loggers ( tcx) ;
70
+ ;
71
+ init_late_loggers ( handler , tcx) ;
71
72
if !tcx. sess . crate_types ( ) . contains ( & CrateType :: Executable ) {
72
73
tcx. sess . fatal ( "miri only makes sense on bin crates" ) ;
73
74
}
@@ -181,7 +182,7 @@ macro_rules! show_error {
181
182
( $( $tt: tt) * ) => { show_error( & format_args!( $( $tt) * ) ) } ;
182
183
}
183
184
184
- fn init_early_loggers ( ) {
185
+ fn init_early_loggers ( handler : & EarlyErrorHandler ) {
185
186
// Note that our `extern crate log` is *not* the same as rustc's; as a result, we have to
186
187
// initialize them both, and we always initialize `miri`'s first.
187
188
let env = env_logger:: Env :: new ( ) . filter ( "MIRI_LOG" ) . write_style ( "MIRI_LOG_STYLE" ) ;
@@ -195,11 +196,11 @@ fn init_early_loggers() {
195
196
// later with our custom settings, and *not* log anything for what happens before
196
197
// `miri` gets started.
197
198
if env:: var_os ( "RUSTC_LOG" ) . is_some ( ) {
198
- rustc_driver:: init_rustc_env_logger ( ) ;
199
+ rustc_driver:: init_rustc_env_logger ( handler ) ;
199
200
}
200
201
}
201
202
202
- fn init_late_loggers ( tcx : TyCtxt < ' _ > ) {
203
+ fn init_late_loggers ( handler : & EarlyErrorHandler , tcx : TyCtxt < ' _ > ) {
203
204
// We initialize loggers right before we start evaluation. We overwrite the `RUSTC_LOG`
204
205
// env var if it is not set, control it based on `MIRI_LOG`.
205
206
// (FIXME: use `var_os`, but then we need to manually concatenate instead of `format!`.)
@@ -218,7 +219,7 @@ fn init_late_loggers(tcx: TyCtxt<'_>) {
218
219
} else {
219
220
env:: set_var ( "RUSTC_LOG" , & var) ;
220
221
}
221
- rustc_driver:: init_rustc_env_logger ( ) ;
222
+ rustc_driver:: init_rustc_env_logger ( handler ) ;
222
223
}
223
224
}
224
225
@@ -284,6 +285,8 @@ fn parse_comma_list<T: FromStr>(input: &str) -> Result<Vec<T>, T::Err> {
284
285
}
285
286
286
287
fn main ( ) {
288
+ let handler = EarlyErrorHandler :: new ( ErrorOutputType :: default ( ) ) ;
289
+
287
290
// Snapshot a copy of the environment before `rustc` starts messing with it.
288
291
// (`install_ice_hook` might change `RUST_BACKTRACE`.)
289
292
let env_snapshot = env:: vars_os ( ) . collect :: < Vec < _ > > ( ) ;
@@ -292,7 +295,7 @@ fn main() {
292
295
if let Some ( crate_kind) = env:: var_os ( "MIRI_BE_RUSTC" ) {
293
296
// Earliest rustc setup.
294
297
rustc_driver:: install_ice_hook ( rustc_driver:: DEFAULT_BUG_REPORT_URL , |_| ( ) ) ;
295
- rustc_driver:: init_rustc_env_logger ( ) ;
298
+ rustc_driver:: init_rustc_env_logger ( & handler ) ;
296
299
297
300
let target_crate = if crate_kind == "target" {
298
301
true
@@ -314,7 +317,7 @@ fn main() {
314
317
rustc_driver:: install_ice_hook ( "https://github.com/rust-lang/miri/issues/new" , |_| ( ) ) ;
315
318
316
319
// Init loggers the Miri way.
317
- init_early_loggers ( ) ;
320
+ init_early_loggers ( & handler ) ;
318
321
319
322
// Parse our arguments and split them across `rustc` and `miri`.
320
323
let mut miri_config = miri:: MiriConfig :: default ( ) ;
0 commit comments