Skip to content

Commit 4fc8542

Browse files
committed
Auto merge of #1221 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 704228d + 76ee8ff commit 4fc8542

File tree

4 files changed

+17
-20
lines changed

4 files changed

+17
-20
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
303d8aff6092709edd4dbd35b1c88e9aa40bf6d8
1+
c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be

src/bin/miri.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,22 @@ extern crate log;
77
extern crate log_settings;
88
extern crate miri;
99
extern crate rustc;
10-
extern crate rustc_codegen_utils;
1110
extern crate rustc_driver;
12-
extern crate rustc_errors;
1311
extern crate rustc_hir;
1412
extern crate rustc_interface;
15-
extern crate rustc_metadata;
16-
extern crate rustc_span;
13+
extern crate rustc_session;
1714

1815
use std::convert::TryFrom;
1916
use std::env;
2017
use std::str::FromStr;
2118

2219
use hex::FromHexError;
2320

21+
use rustc_session::CtfeBacktrace;
2422
use rustc_driver::Compilation;
2523
use rustc_hir::def_id::LOCAL_CRATE;
2624
use rustc_interface::{interface, Queries};
25+
use rustc::ty::TyCtxt;
2726

2827
struct MiriCompilerCalls {
2928
miri_config: miri::MiriConfig,
@@ -35,10 +34,10 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
3534
compiler: &interface::Compiler,
3635
queries: &'tcx Queries<'tcx>,
3736
) -> Compilation {
38-
init_late_loggers();
3937
compiler.session().abort_if_errors();
4038

4139
queries.global_ctxt().unwrap().peek_mut().enter(|tcx| {
40+
init_late_loggers(tcx);
4241
let (entry_def_id, _) = tcx.entry_fn(LOCAL_CRATE).expect("no main function found!");
4342
let mut config = self.miri_config.clone();
4443

@@ -72,7 +71,7 @@ fn init_early_loggers() {
7271
}
7372
}
7473

75-
fn init_late_loggers() {
74+
fn init_late_loggers(tcx: TyCtxt<'_>) {
7675
// We initialize loggers right before we start evaluation. We overwrite the `RUSTC_LOG`
7776
// env var if it is not set, control it based on `MIRI_LOG`.
7877
if let Ok(var) = env::var("MIRI_LOG") {
@@ -96,10 +95,13 @@ fn init_late_loggers() {
9695

9796
// If `MIRI_BACKTRACE` is set and `RUSTC_CTFE_BACKTRACE` is not, set `RUSTC_CTFE_BACKTRACE`.
9897
// 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;
103105
}
104106
}
105107

src/machine.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,10 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
265265
#[inline(always)]
266266
fn assert_panic(
267267
ecx: &mut InterpCx<'mir, 'tcx, Self>,
268-
span: Span,
269268
msg: &mir::AssertMessage<'tcx>,
270269
unwind: Option<mir::BasicBlock>,
271270
) -> InterpResult<'tcx> {
272-
ecx.assert_panic(span, msg, unwind)
271+
ecx.assert_panic(msg, unwind)
273272
}
274273

275274
#[inline(always)]

src/shims/panic.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use rustc::mir;
1515
use rustc::ty::{self, layout::LayoutOf};
1616
use rustc_target::spec::PanicStrategy;
17-
use rustc_span::source_map::Span;
1817

1918
use crate::*;
2019

@@ -176,7 +175,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
176175

177176
fn assert_panic(
178177
&mut self,
179-
span: Span,
180178
msg: &mir::AssertMessage<'tcx>,
181179
unwind: Option<mir::BasicBlock>,
182180
) -> InterpResult<'tcx> {
@@ -187,19 +185,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
187185
BoundsCheck { ref index, ref len } => {
188186
// Forward to `panic_bounds_check` lang item.
189187

190-
// First arg: Caller location.
191-
let location = this.alloc_caller_location_for_span(span);
192-
// Second arg: index.
188+
// First arg: index.
193189
let index = this.read_scalar(this.eval_operand(index, None)?)?;
194-
// Third arg: len.
190+
// Second arg: len.
195191
let len = this.read_scalar(this.eval_operand(len, None)?)?;
196192

197193
// Call the lang item.
198194
let panic_bounds_check = this.tcx.lang_items().panic_bounds_check_fn().unwrap();
199195
let panic_bounds_check = ty::Instance::mono(this.tcx.tcx, panic_bounds_check);
200196
this.call_function(
201197
panic_bounds_check,
202-
&[location.ptr.into(), index.into(), len.into()],
198+
&[index.into(), len.into()],
203199
None,
204200
StackPopCleanup::Goto { ret: None, unwind },
205201
)?;

0 commit comments

Comments
 (0)