|
14 | 14 | use rustc::dep_graph::DepNode;
|
15 | 15 | use rustc::middle::infer::{self, InferCtxt};
|
16 | 16 | use rustc::middle::traits;
|
17 |
| -use rustc::middle::ty::{self, Ty, TyCtxt}; |
18 | 17 | use rustc::middle::ty::fold::TypeFoldable;
|
| 18 | +use rustc::middle::ty::{self, Ty, TyCtxt}; |
19 | 19 | use rustc::mir::repr::*;
|
20 |
| -use rustc::mir::mir_map::MirMap; |
21 | 20 | use rustc::mir::tcx::LvalueTy;
|
22 |
| -use rustc::mir::transform::{MirMapPass, Pass}; |
| 21 | +use rustc::mir::transform::{MirPass, Pass}; |
23 | 22 | use rustc::mir::visit::{self, Visitor};
|
24 |
| - |
25 |
| -use syntax::codemap::{Span, DUMMY_SP}; |
26 | 23 | use std::fmt;
|
| 24 | +use syntax::ast::NodeId; |
| 25 | +use syntax::codemap::{Span, DUMMY_SP}; |
27 | 26 |
|
28 | 27 | macro_rules! span_mirbug {
|
29 | 28 | ($context:expr, $elem:expr, $($message:tt)*) => ({
|
@@ -574,29 +573,27 @@ impl TypeckMir {
|
574 | 573 | }
|
575 | 574 | }
|
576 | 575 |
|
577 |
| -impl<'tcx> MirMapPass<'tcx> for TypeckMir { |
578 |
| - fn run_pass(&mut self, tcx: &TyCtxt<'tcx>, map: &mut MirMap<'tcx>) { |
| 576 | +impl<'tcx> MirPass<'tcx> for TypeckMir { |
| 577 | + fn run_pass(&mut self, tcx: &TyCtxt<'tcx>, id: NodeId, mir: &mut Mir<'tcx>) { |
579 | 578 | if tcx.sess.err_count() > 0 {
|
580 | 579 | // compiling a broken program can obviously result in a
|
581 | 580 | // broken MIR, so try not to report duplicate errors.
|
582 | 581 | return;
|
583 | 582 | }
|
584 |
| - for (&id, mir) in &mut map.map { |
585 |
| - let _task = tcx.dep_graph.in_task(DepNode::MirTypeck(id)); |
586 |
| - let param_env = ty::ParameterEnvironment::for_item(tcx, id); |
587 |
| - let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(param_env)); |
588 |
| - let mut checker = TypeChecker::new(&infcx); |
589 |
| - { |
590 |
| - let mut verifier = TypeVerifier::new(&mut checker, mir); |
591 |
| - verifier.visit_mir(mir); |
592 |
| - if verifier.errors_reported { |
593 |
| - // don't do further checks to avoid ICEs |
594 |
| - continue; |
595 |
| - } |
| 583 | + let _task = tcx.dep_graph.in_task(DepNode::MirTypeck(id)); |
| 584 | + let param_env = ty::ParameterEnvironment::for_item(tcx, id); |
| 585 | + let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(param_env)); |
| 586 | + let mut checker = TypeChecker::new(&infcx); |
| 587 | + { |
| 588 | + let mut verifier = TypeVerifier::new(&mut checker, mir); |
| 589 | + verifier.visit_mir(mir); |
| 590 | + if verifier.errors_reported { |
| 591 | + // don't do further checks to avoid ICEs |
| 592 | + return; |
596 | 593 | }
|
597 |
| - checker.typeck_mir(mir); |
598 |
| - checker.verify_obligations(mir); |
599 | 594 | }
|
| 595 | + checker.typeck_mir(mir); |
| 596 | + checker.verify_obligations(mir); |
600 | 597 | }
|
601 | 598 | }
|
602 | 599 |
|
|
0 commit comments