ppaux::parameterized $sometimes panics, let's catch that.
This commit is contained in:
parent
f731766805
commit
1b94e06a1a
1 changed files with 9 additions and 1 deletions
|
@ -1093,12 +1093,20 @@ fn report(tcx: TyCtxt, ecx: &EvalContext, e: EvalError) {
|
||||||
use rustc::util::ppaux;
|
use rustc::util::ppaux;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
struct Instance<'tcx>(DefId, &'tcx subst::Substs<'tcx>);
|
struct Instance<'tcx>(DefId, &'tcx subst::Substs<'tcx>);
|
||||||
|
impl<'tcx> ::std::panic::UnwindSafe for Instance<'tcx> {}
|
||||||
|
impl<'tcx> ::std::panic::RefUnwindSafe for Instance<'tcx> {}
|
||||||
impl<'tcx> fmt::Display for Instance<'tcx> {
|
impl<'tcx> fmt::Display for Instance<'tcx> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
ppaux::parameterized(f, self.1, self.0, ppaux::Ns::Value, &[])
|
ppaux::parameterized(f, self.1, self.0, ppaux::Ns::Value, &[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err.span_note(span, &format!("inside call to {}", Instance(def_id, substs)));
|
let inst = Instance(def_id, substs);
|
||||||
|
match ::std::panic::catch_unwind(|| {
|
||||||
|
format!("inside call to {}", inst)
|
||||||
|
}) {
|
||||||
|
Ok(msg) => err.span_note(span, &msg),
|
||||||
|
Err(_) => err.span_note(span, &format!("ppaux::parameterized failed: {:?}, {:?}", def_id, substs)),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue