Skip to content

Commit 58b0506

Browse files
spastorinonikomatsakis
authored andcommitted
Move MirVisitable to visit.rs
1 parent 93afb1a commit 58b0506

File tree

3 files changed

+27
-24
lines changed

3 files changed

+27
-24
lines changed

src/librustc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#![feature(const_fn)]
4747
#![feature(core_intrinsics)]
4848
#![feature(drain_filter)]
49+
#![feature(dyn_trait)]
4950
#![feature(from_ref)]
5051
#![feature(i128)]
5152
#![feature(i128_type)]

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;
@@ -358,30 +359,6 @@ fn block<'tcx>(mode: LivenessMode, b: &BasicBlockData<'tcx>, locals: usize) -> D
358359
visitor.defs_uses
359360
}
360361

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

0 commit comments

Comments
 (0)