Skip to content

Commit d0f1f07

Browse files
spastorinonikomatsakis
authored andcommitted
Move MirVisitable to visit.rs
1 parent f944461 commit d0f1f07

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

src/librustc/mir/visit.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,31 @@ macro_rules! make_mir_visitor {
811811
make_mir_visitor!(Visitor,);
812812
make_mir_visitor!(MutVisitor,mut);
813813

814+
pub trait MirVisitable<'tcx> {
815+
fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>);
816+
}
817+
818+
impl<'tcx> MirVisitable<'tcx> for Statement<'tcx> {
819+
fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
820+
{
821+
visitor.visit_statement(location.block, self, location)
822+
}
823+
}
824+
825+
impl<'tcx> MirVisitable<'tcx> for Terminator<'tcx> {
826+
fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
827+
{
828+
visitor.visit_terminator(location.block, self, location)
829+
}
830+
}
831+
832+
impl<'tcx> MirVisitable<'tcx> for Option<Terminator<'tcx>> {
833+
fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
834+
{
835+
visitor.visit_terminator(location.block, self.as_ref().unwrap(), location)
836+
}
837+
}
838+
814839
/// Extra information passed to `visit_ty` and friends to give context
815840
/// about where the type etc appears.
816841
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]

src/librustc_mir/util/liveness.rs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ use rustc_data_structures::indexed_vec::{Idx, IndexVec};
3939
use rustc_data_structures::indexed_set::IdxSetBuf;
4040
use util::pretty::{dump_enabled, write_basic_block, write_mir_intro};
4141
use rustc::ty::item_path;
42+
use rustc::mir::visit::MirVisitable;
4243
use std::path::{Path, PathBuf};
4344
use std::fs;
4445
use rustc::ty::TyCtxt;
@@ -355,30 +356,6 @@ fn block<'tcx>(mode: LivenessMode, b: &BasicBlockData<'tcx>, locals: usize) -> D
355356
visitor.defs_uses
356357
}
357358

358-
trait MirVisitable<'tcx> {
359-
fn apply<V>(&self, location: Location, visitor: &mut V)
360-
where
361-
V: Visitor<'tcx>;
362-
}
363-
364-
impl<'tcx> MirVisitable<'tcx> for Statement<'tcx> {
365-
fn apply<V>(&self, location: Location, visitor: &mut V)
366-
where
367-
V: Visitor<'tcx>,
368-
{
369-
visitor.visit_statement(location.block, self, location)
370-
}
371-
}
372-
373-
impl<'tcx> MirVisitable<'tcx> for Option<Terminator<'tcx>> {
374-
fn apply<V>(&self, location: Location, visitor: &mut V)
375-
where
376-
V: Visitor<'tcx>,
377-
{
378-
visitor.visit_terminator(location.block, self.as_ref().unwrap(), location)
379-
}
380-
}
381-
382359
pub fn dump_mir<'a, 'tcx>(
383360
tcx: TyCtxt<'a, 'tcx, 'tcx>,
384361
pass_name: &str,

0 commit comments

Comments
 (0)