Skip to content

Commit

Permalink
Add some missing method impls to MIR region eraser.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Mar 22, 2017
1 parent 439bf13 commit bb24305
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/librustc_mir/transform/erase_regions.rs
Expand Up @@ -13,7 +13,7 @@
//! care erasing regions all over the place.

use rustc::ty::subst::Substs;
use rustc::ty::{Ty, TyCtxt};
use rustc::ty::{Ty, TyCtxt, ReErased, ClosureSubsts};
use rustc::mir::*;
use rustc::mir::visit::MutVisitor;
use rustc::mir::transform::{MirPass, MirSource, Pass};
Expand All @@ -39,6 +39,23 @@ impl<'a, 'tcx> MutVisitor<'tcx> for EraseRegionsVisitor<'a, 'tcx> {
fn visit_substs(&mut self, substs: &mut &'tcx Substs<'tcx>) {
*substs = self.tcx.erase_regions(&{*substs});
}

fn visit_rvalue(&mut self, rvalue: &mut Rvalue<'tcx>, location: Location) {
match *rvalue {
Rvalue::Ref(ref mut r, _, _) => {
*r = self.tcx.mk_region(ReErased);
}
_ => {
/* only the above variant contains regions */
}
}
self.super_rvalue(rvalue, location);
}

fn visit_closure_substs(&mut self,
substs: &mut ClosureSubsts<'tcx>) {
*substs = self.tcx.erase_regions(substs);
}
}

pub struct EraseRegions;
Expand Down

0 comments on commit bb24305

Please sign in to comment.