From 34dfbc3fef3fb02c36beb982523ce8d9d90838e7 Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Wed, 22 Apr 2020 18:56:23 -0700 Subject: [PATCH] Add module docs and restrict visibility --- src/librustc_middle/mir/mod.rs | 2 +- src/librustc_middle/mir/predecessors.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/librustc_middle/mir/mod.rs b/src/librustc_middle/mir/mod.rs index 566817ea0d0..858ab0dbe00 100644 --- a/src/librustc_middle/mir/mod.rs +++ b/src/librustc_middle/mir/mod.rs @@ -164,7 +164,7 @@ pub struct Body<'tcx> { /// FIXME(oli-obk): rewrite the promoted during promotion to eliminate the cell components. pub ignore_interior_mut_in_const_validation: bool, - pub predecessor_cache: PredecessorCache, + predecessor_cache: PredecessorCache, } impl<'tcx> Body<'tcx> { diff --git a/src/librustc_middle/mir/predecessors.rs b/src/librustc_middle/mir/predecessors.rs index 8f1f9278521..9508365886a 100644 --- a/src/librustc_middle/mir/predecessors.rs +++ b/src/librustc_middle/mir/predecessors.rs @@ -1,3 +1,5 @@ +//! Lazily compute the reverse control-flow graph for the MIR. + use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::sync::{Lock, Lrc}; use rustc_index::vec::IndexVec; @@ -10,13 +12,13 @@ pub type Predecessors = IndexVec>; #[derive(Clone, Debug)] -pub struct PredecessorCache { +pub(super) struct PredecessorCache { cache: Lock>>, } impl PredecessorCache { #[inline] - pub fn new() -> Self { + pub(super) fn new() -> Self { PredecessorCache { cache: Lock::new(None) } } @@ -27,7 +29,7 @@ pub fn new() -> Self { /// callers of `invalidate` have a unique reference to the MIR and thus to the predecessor /// cache. This means we don't actually need to take a lock when `invalidate` is called. #[inline] - pub fn invalidate(&mut self) { + pub(super) fn invalidate(&mut self) { *self.cache.get_mut() = None; } @@ -37,7 +39,7 @@ pub fn invalidate(&mut self) { /// `cache` is only held inside this function. As long as no other locks are taken while /// computing the predecessor graph, deadlock is impossible. #[inline] - pub fn compute( + pub(super) fn compute( &self, basic_blocks: &IndexVec>, ) -> Lrc { -- GitLab