@@ -7,23 +7,22 @@ extern crate log;
7
7
extern crate log_settings;
8
8
extern crate miri;
9
9
extern crate rustc;
10
- extern crate rustc_codegen_utils;
11
10
extern crate rustc_driver;
12
- extern crate rustc_errors;
13
11
extern crate rustc_hir;
14
12
extern crate rustc_interface;
15
- extern crate rustc_metadata;
16
- extern crate rustc_span;
13
+ extern crate rustc_session;
17
14
18
15
use std:: convert:: TryFrom ;
19
16
use std:: env;
20
17
use std:: str:: FromStr ;
21
18
22
19
use hex:: FromHexError ;
23
20
21
+ use rustc_session:: CtfeBacktrace ;
24
22
use rustc_driver:: Compilation ;
25
23
use rustc_hir:: def_id:: LOCAL_CRATE ;
26
24
use rustc_interface:: { interface, Queries } ;
25
+ use rustc:: ty:: TyCtxt ;
27
26
28
27
struct MiriCompilerCalls {
29
28
miri_config : miri:: MiriConfig ,
@@ -35,10 +34,10 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
35
34
compiler : & interface:: Compiler ,
36
35
queries : & ' tcx Queries < ' tcx > ,
37
36
) -> Compilation {
38
- init_late_loggers ( ) ;
39
37
compiler. session ( ) . abort_if_errors ( ) ;
40
38
41
39
queries. global_ctxt ( ) . unwrap ( ) . peek_mut ( ) . enter ( |tcx| {
40
+ init_late_loggers ( tcx) ;
42
41
let ( entry_def_id, _) = tcx. entry_fn ( LOCAL_CRATE ) . expect ( "no main function found!" ) ;
43
42
let mut config = self . miri_config . clone ( ) ;
44
43
@@ -72,7 +71,7 @@ fn init_early_loggers() {
72
71
}
73
72
}
74
73
75
- fn init_late_loggers ( ) {
74
+ fn init_late_loggers ( tcx : TyCtxt < ' _ > ) {
76
75
// We initialize loggers right before we start evaluation. We overwrite the `RUSTC_LOG`
77
76
// env var if it is not set, control it based on `MIRI_LOG`.
78
77
if let Ok ( var) = env:: var ( "MIRI_LOG" ) {
@@ -96,10 +95,13 @@ fn init_late_loggers() {
96
95
97
96
// If `MIRI_BACKTRACE` is set and `RUSTC_CTFE_BACKTRACE` is not, set `RUSTC_CTFE_BACKTRACE`.
98
97
// Do this late, so we ideally only apply this to Miri's errors.
99
- if let Ok ( var) = env:: var ( "MIRI_BACKTRACE" ) {
100
- if env:: var ( "RUSTC_CTFE_BACKTRACE" ) == Err ( env:: VarError :: NotPresent ) {
101
- env:: set_var ( "RUSTC_CTFE_BACKTRACE" , & var) ;
102
- }
98
+ if let Ok ( val) = env:: var ( "MIRI_BACKTRACE" ) {
99
+ let ctfe_backtrace = match & * val {
100
+ "immediate" => CtfeBacktrace :: Immediate ,
101
+ "0" => CtfeBacktrace :: Disabled ,
102
+ _ => CtfeBacktrace :: Capture ,
103
+ } ;
104
+ * tcx. sess . ctfe_backtrace . borrow_mut ( ) = ctfe_backtrace;
103
105
}
104
106
}
105
107
0 commit comments