Skip to content

Commit

Permalink
validator: print MIR instance on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-schievink committed Jun 14, 2020
1 parent 99d30da commit 9014df5
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/librustc_mir/transform/validate.rs
Expand Up @@ -9,7 +9,6 @@ use rustc_middle::{
},
ty::{self, ParamEnv, TyCtxt},
};
use rustc_span::def_id::DefId;

#[derive(Copy, Clone, Debug)]
enum EdgeKind {
Expand All @@ -24,15 +23,14 @@ pub struct Validator {

impl<'tcx> MirPass<'tcx> for Validator {
fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
let def_id = source.def_id();
let param_env = tcx.param_env(def_id);
TypeChecker { when: &self.when, def_id, body, tcx, param_env }.visit_body(body);
let param_env = tcx.param_env(source.def_id());
TypeChecker { when: &self.when, source, body, tcx, param_env }.visit_body(body);
}
}

struct TypeChecker<'a, 'tcx> {
when: &'a str,
def_id: DefId,
source: MirSource<'tcx>,
body: &'a Body<'tcx>,
tcx: TyCtxt<'tcx>,
param_env: ParamEnv<'tcx>,
Expand All @@ -47,7 +45,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
span,
&format!(
"broken MIR in {:?} ({}) at {:?}:\n{}",
self.def_id,
self.source.instance,
self.when,
location,
msg.as_ref()
Expand Down

0 comments on commit 9014df5

Please sign in to comment.