ppaux::parameterized $sometimes panics, let's catch that.

This commit is contained in:
Oliver Schneider 2016-09-15 16:10:58 +02:00
parent f731766805
commit 1b94e06a1a
No known key found for this signature in database
GPG key ID: 56D6EEA0FC67AC46

View file

@ -1093,12 +1093,20 @@ fn report(tcx: TyCtxt, ecx: &EvalContext, e: EvalError) {
use rustc::util::ppaux;
use std::fmt;
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> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
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();
}