Rollup merge of #71712 - RalfJung:error-backtrace, r=oli-obk
Miri: port error backtraces to std::backtrace No need to pull in an external dependency if libstd already includes this feature (using the same dependency internally, but... still). r? @oli-obk
This commit is contained in:
commit
cd824a5232
|
@ -3978,7 +3978,6 @@ name = "rustc_middle"
|
|||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"arena",
|
||||
"backtrace",
|
||||
"bitflags",
|
||||
"byteorder",
|
||||
"log",
|
||||
|
|
|
@ -30,7 +30,6 @@ rustc_index = { path = "../librustc_index" }
|
|||
rustc_serialize = { path = "../libserialize", package = "serialize" }
|
||||
rustc_ast = { path = "../librustc_ast" }
|
||||
rustc_span = { path = "../librustc_span" }
|
||||
backtrace = "0.3.40"
|
||||
byteorder = { version = "1.3" }
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
measureme = "0.7.1"
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
//! This API is completely unstable and subject to change.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![feature(backtrace)]
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(box_patterns)]
|
||||
#![feature(box_syntax)]
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::ty::query::TyCtxtAt;
|
|||
use crate::ty::tls;
|
||||
use crate::ty::{self, layout, Ty};
|
||||
|
||||
use backtrace::Backtrace;
|
||||
use rustc_data_structures::sync::Lock;
|
||||
use rustc_errors::{struct_span_err, DiagnosticBuilder, ErrorReported};
|
||||
use rustc_hir as hir;
|
||||
|
@ -15,7 +14,7 @@ use rustc_macros::HashStable;
|
|||
use rustc_session::CtfeBacktrace;
|
||||
use rustc_span::{def_id::DefId, Pos, Span};
|
||||
use rustc_target::abi::{Align, Size};
|
||||
use std::{any::Any, fmt, mem};
|
||||
use std::{any::Any, backtrace::Backtrace, fmt, mem};
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable, RustcEncodable, RustcDecodable)]
|
||||
pub enum ErrorHandled {
|
||||
|
@ -219,16 +218,15 @@ impl fmt::Display for InterpErrorInfo<'_> {
|
|||
}
|
||||
|
||||
impl InterpErrorInfo<'_> {
|
||||
pub fn print_backtrace(&mut self) {
|
||||
if let Some(ref mut backtrace) = self.backtrace {
|
||||
print_backtrace(&mut *backtrace);
|
||||
pub fn print_backtrace(&self) {
|
||||
if let Some(backtrace) = self.backtrace.as_ref() {
|
||||
print_backtrace(backtrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn print_backtrace(backtrace: &mut Backtrace) {
|
||||
backtrace.resolve();
|
||||
eprintln!("\n\nAn error occurred in miri:\n{:?}", backtrace);
|
||||
fn print_backtrace(backtrace: &Backtrace) {
|
||||
eprintln!("\n\nAn error occurred in miri:\n{}", backtrace);
|
||||
}
|
||||
|
||||
impl From<ErrorHandled> for InterpErrorInfo<'_> {
|
||||
|
@ -255,11 +253,11 @@ impl<'tcx> From<InterpError<'tcx>> for InterpErrorInfo<'tcx> {
|
|||
|
||||
let backtrace = match capture_backtrace {
|
||||
CtfeBacktrace::Disabled => None,
|
||||
CtfeBacktrace::Capture => Some(Box::new(Backtrace::new_unresolved())),
|
||||
CtfeBacktrace::Capture => Some(Box::new(Backtrace::force_capture())),
|
||||
CtfeBacktrace::Immediate => {
|
||||
// Print it now.
|
||||
let mut backtrace = Backtrace::new_unresolved();
|
||||
print_backtrace(&mut backtrace);
|
||||
let backtrace = Backtrace::force_capture();
|
||||
print_backtrace(&backtrace);
|
||||
None
|
||||
}
|
||||
};
|
||||
|
|
|
@ -52,7 +52,7 @@ impl Error for ConstEvalErrKind {}
|
|||
/// Should be called only if the error is actually going to to be reported!
|
||||
pub fn error_to_const_error<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>>(
|
||||
ecx: &InterpCx<'mir, 'tcx, M>,
|
||||
mut error: InterpErrorInfo<'tcx>,
|
||||
error: InterpErrorInfo<'tcx>,
|
||||
) -> ConstEvalErr<'tcx> {
|
||||
error.print_backtrace();
|
||||
let stacktrace = ecx.generate_stacktrace();
|
||||
|
|
Loading…
Reference in New Issue