Skip to content

Commit

Permalink
use the type name as the pass name
Browse files Browse the repository at this point in the history
  • Loading branch information
arielb1 authored and Ariel Ben-Yehuda committed Jun 9, 2016
1 parent 065a264 commit f5b1ba6
Show file tree
Hide file tree
Showing 13 changed files with 12 additions and 27 deletions.
1 change: 1 addition & 0 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#![feature(box_syntax)]
#![feature(collections)]
#![feature(const_fn)]
#![feature(core_intrinsics)]
#![feature(enumset)]
#![feature(iter_arith)]
#![feature(libc)]
Expand Down
4 changes: 3 additions & 1 deletion src/librustc/mir/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ pub trait Pass {
fn dep_node(&self, def_id: DefId) -> DepNode<DefId> {
DepNode::MirPass(def_id)
}
fn name(&self) -> &str;
fn name(&self) -> &str {
unsafe { ::std::intrinsics::type_name::<Self>() }
}
fn disambiguator<'a>(&'a self) -> Option<Box<fmt::Display+'a>> { None }
}

Expand Down
4 changes: 1 addition & 3 deletions src/librustc_borrowck/borrowck/mir/elaborate_drops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateDrops {
}
}

impl Pass for ElaborateDrops {
fn name(&self) -> &str { "elaborate-drops" }
}
impl Pass for ElaborateDrops {}

struct InitializationData {
live: IdxSetBuf<MovePathIndex>,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
passes.push_pass(box mir::transform::simplify_cfg::SimplifyCfg::new("elaborate-drops"));

passes.push_pass(box mir::transform::add_call_guards::AddCallGuards);
passes.push_pass(box mir::transform::dump_mir::Marker("pre-trans"));
passes.push_pass(box mir::transform::dump_mir::Marker("PreTrans"));

passes.run_passes(tcx, &mut mir_map);
});
Expand Down
4 changes: 1 addition & 3 deletions src/librustc_mir/transform/add_call_guards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,4 @@ impl<'tcx> MirPass<'tcx> for AddCallGuards {
}
}

impl Pass for AddCallGuards {
fn name(&self) -> &str { "add-call-guards" }
}
impl Pass for AddCallGuards {}
4 changes: 1 addition & 3 deletions src/librustc_mir/transform/dump_mir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,4 @@ impl<'tcx> MirPassHook<'tcx> for DumpMir {
}
}

impl<'b> Pass for DumpMir {
fn name(&self) -> &str { "dump-mir" }
}
impl<'b> Pass for DumpMir {}
4 changes: 1 addition & 3 deletions src/librustc_mir/transform/erase_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for EraseRegionsVisitor<'a, 'tcx> {

pub struct EraseRegions;

impl Pass for EraseRegions {
fn name(&self) -> &str { "erase-regions" }
}
impl Pass for EraseRegions {}

impl<'tcx> MirPass<'tcx> for EraseRegions {
fn run_pass<'a>(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
Expand Down
4 changes: 1 addition & 3 deletions src/librustc_mir/transform/no_landing_pads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,4 @@ impl<'tcx> MirPass<'tcx> for NoLandingPads {
}
}

impl Pass for NoLandingPads {
fn name(&self) -> &str { "no-landing-pads" }
}
impl Pass for NoLandingPads {}
4 changes: 1 addition & 3 deletions src/librustc_mir/transform/qualify_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -906,9 +906,7 @@ fn qualify_const_item_cached<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,

pub struct QualifyAndPromoteConstants;

impl Pass for QualifyAndPromoteConstants {
fn name(&self) -> &str { "qualify-consts" }
}
impl Pass for QualifyAndPromoteConstants {}

impl<'tcx> MirMapPass<'tcx> for QualifyAndPromoteConstants {
fn run_pass<'a>(&mut self,
Expand Down
1 change: 0 additions & 1 deletion src/librustc_mir/transform/simplify_branches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ impl<'l, 'tcx> MirPass<'tcx> for SimplifyBranches<'l> {
}

impl<'l> Pass for SimplifyBranches<'l> {
fn name(&self) -> &str { "simplify-branches" }
fn disambiguator<'a>(&'a self) -> Option<Box<fmt::Display+'a>> {
Some(Box::new(self.label))
}
Expand Down
1 change: 0 additions & 1 deletion src/librustc_mir/transform/simplify_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ impl<'l, 'tcx> MirPass<'tcx> for SimplifyCfg<'l> {
}

impl<'l> Pass for SimplifyCfg<'l> {
fn name(&self) -> &str { "simplify-cfg" }
fn disambiguator<'a>(&'a self) -> Option<Box<fmt::Display+'a>> {
Some(Box::new(self.label))
}
Expand Down
2 changes: 0 additions & 2 deletions src/librustc_mir/transform/type_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,4 @@ impl Pass for TypeckMir {
fn dep_node(&self, def_id: DefId) -> DepNode<DefId> {
DepNode::MirTypeck(def_id)
}

fn name(&self) -> &str { "typeck-mir" }
}
4 changes: 1 addition & 3 deletions src/test/run-pass-fulldeps/auxiliary/dummy_mir_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ use rustc_plugin::Registry;

struct Pass;

impl transform::Pass for Pass {
fn name(&self) -> &str { "dummy-mir-pass" }
}
impl transform::Pass for Pass {}

impl<'tcx> MirPass<'tcx> for Pass {
fn run_pass<'a>(&mut self, _: TyCtxt<'a, 'tcx, 'tcx>,
Expand Down

0 comments on commit f5b1ba6

Please sign in to comment.