Rollup merge of #64207 - sinkuu:pub_dataflow, r=tmandry

Make rustc_mir::dataflow module pub (for clippy)

I'm working on fixing false-positives of a MIR-based clippy lint (https://github.com/rust-lang/rust-clippy/pull/4509), and in need of the dataflow infrastructure.
This commit is contained in:
Tyler Mandry 2019-09-18 10:58:03 -07:00 committed by GitHub
commit e8ded849ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -56,7 +56,7 @@ where
/// string (as well as that of rendering up-front); in exchange, you /// string (as well as that of rendering up-front); in exchange, you
/// don't have to hand over ownership of your value or deal with /// don't have to hand over ownership of your value or deal with
/// borrowing it. /// borrowing it.
pub(crate) struct DebugFormatted(String); pub struct DebugFormatted(String);
impl DebugFormatted { impl DebugFormatted {
pub fn new(input: &dyn fmt::Debug) -> DebugFormatted { pub fn new(input: &dyn fmt::Debug) -> DebugFormatted {
@ -70,7 +70,7 @@ impl fmt::Debug for DebugFormatted {
} }
} }
pub(crate) trait Dataflow<'tcx, BD: BitDenotation<'tcx>> { pub trait Dataflow<'tcx, BD: BitDenotation<'tcx>> {
/// Sets up and runs the dataflow problem, using `p` to render results if /// Sets up and runs the dataflow problem, using `p` to render results if
/// implementation so chooses. /// implementation so chooses.
fn dataflow<P>(&mut self, p: P) where P: Fn(&BD, BD::Idx) -> DebugFormatted { fn dataflow<P>(&mut self, p: P) where P: Fn(&BD, BD::Idx) -> DebugFormatted {
@ -121,7 +121,7 @@ pub struct MoveDataParamEnv<'tcx> {
pub(crate) param_env: ty::ParamEnv<'tcx>, pub(crate) param_env: ty::ParamEnv<'tcx>,
} }
pub(crate) fn do_dataflow<'a, 'tcx, BD, P>( pub fn do_dataflow<'a, 'tcx, BD, P>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
body: &'a Body<'tcx>, body: &'a Body<'tcx>,
def_id: DefId, def_id: DefId,
@ -565,7 +565,7 @@ pub struct GenKill<T> {
pub(crate) kill_set: T, pub(crate) kill_set: T,
} }
type GenKillSet<T> = GenKill<HybridBitSet<T>>; pub type GenKillSet<T> = GenKill<HybridBitSet<T>>;
impl<T> GenKill<T> { impl<T> GenKill<T> {
/// Creates a new tuple where `gen_set == kill_set == elem`. /// Creates a new tuple where `gen_set == kill_set == elem`.
@ -580,28 +580,28 @@ impl<T> GenKill<T> {
} }
impl<E:Idx> GenKillSet<E> { impl<E:Idx> GenKillSet<E> {
pub(crate) fn clear(&mut self) { pub fn clear(&mut self) {
self.gen_set.clear(); self.gen_set.clear();
self.kill_set.clear(); self.kill_set.clear();
} }
fn gen(&mut self, e: E) { pub fn gen(&mut self, e: E) {
self.gen_set.insert(e); self.gen_set.insert(e);
self.kill_set.remove(e); self.kill_set.remove(e);
} }
fn gen_all(&mut self, i: impl IntoIterator<Item: Borrow<E>>) { pub fn gen_all(&mut self, i: impl IntoIterator<Item: Borrow<E>>) {
for j in i { for j in i {
self.gen(*j.borrow()); self.gen(*j.borrow());
} }
} }
fn kill(&mut self, e: E) { pub fn kill(&mut self, e: E) {
self.gen_set.remove(e); self.gen_set.remove(e);
self.kill_set.insert(e); self.kill_set.insert(e);
} }
fn kill_all(&mut self, i: impl IntoIterator<Item: Borrow<E>>) { pub fn kill_all(&mut self, i: impl IntoIterator<Item: Borrow<E>>) {
for j in i { for j in i {
self.kill(*j.borrow()); self.kill(*j.borrow());
} }

View File

@ -35,7 +35,7 @@ pub mod error_codes;
mod borrow_check; mod borrow_check;
mod build; mod build;
mod dataflow; pub mod dataflow;
mod hair; mod hair;
mod lints; mod lints;
mod shim; mod shim;