Reduce visibilities.

This commit is contained in:
Nicholas Nethercote 2024-10-04 10:04:34 +10:00
parent e3a918ece0
commit 6676cec925
6 changed files with 23 additions and 21 deletions

View File

@ -20,18 +20,18 @@ pub struct BorrowSet<'tcx> {
/// by the `Location` of the assignment statement in which it /// by the `Location` of the assignment statement in which it
/// appears on the right hand side. Thus the location is the map /// appears on the right hand side. Thus the location is the map
/// key, and its position in the map corresponds to `BorrowIndex`. /// key, and its position in the map corresponds to `BorrowIndex`.
pub location_map: FxIndexMap<Location, BorrowData<'tcx>>, pub(crate) location_map: FxIndexMap<Location, BorrowData<'tcx>>,
/// Locations which activate borrows. /// Locations which activate borrows.
/// NOTE: a given location may activate more than one borrow in the future /// NOTE: a given location may activate more than one borrow in the future
/// when more general two-phase borrow support is introduced, but for now we /// when more general two-phase borrow support is introduced, but for now we
/// only need to store one borrow index. /// only need to store one borrow index.
pub activation_map: FxIndexMap<Location, Vec<BorrowIndex>>, pub(crate) activation_map: FxIndexMap<Location, Vec<BorrowIndex>>,
/// Map from local to all the borrows on that local. /// Map from local to all the borrows on that local.
pub local_map: FxIndexMap<mir::Local, FxIndexSet<BorrowIndex>>, pub(crate) local_map: FxIndexMap<mir::Local, FxIndexSet<BorrowIndex>>,
pub locals_state_at_exit: LocalsStateAtExit, pub(crate) locals_state_at_exit: LocalsStateAtExit,
} }
impl<'tcx> Index<BorrowIndex> for BorrowSet<'tcx> { impl<'tcx> Index<BorrowIndex> for BorrowSet<'tcx> {
@ -45,7 +45,7 @@ impl<'tcx> Index<BorrowIndex> for BorrowSet<'tcx> {
/// Location where a two-phase borrow is activated, if a borrow /// Location where a two-phase borrow is activated, if a borrow
/// is in fact a two-phase borrow. /// is in fact a two-phase borrow.
#[derive(Copy, Clone, PartialEq, Eq, Debug)] #[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum TwoPhaseActivation { pub(crate) enum TwoPhaseActivation {
NotTwoPhase, NotTwoPhase,
NotActivated, NotActivated,
ActivatedAt(Location), ActivatedAt(Location),
@ -55,17 +55,17 @@ pub enum TwoPhaseActivation {
pub struct BorrowData<'tcx> { pub struct BorrowData<'tcx> {
/// Location where the borrow reservation starts. /// Location where the borrow reservation starts.
/// In many cases, this will be equal to the activation location but not always. /// In many cases, this will be equal to the activation location but not always.
pub reserve_location: Location, pub(crate) reserve_location: Location,
/// Location where the borrow is activated. /// Location where the borrow is activated.
pub activation_location: TwoPhaseActivation, pub(crate) activation_location: TwoPhaseActivation,
/// What kind of borrow this is /// What kind of borrow this is
pub kind: mir::BorrowKind, pub(crate) kind: mir::BorrowKind,
/// The region for which this borrow is live /// The region for which this borrow is live
pub region: RegionVid, pub(crate) region: RegionVid,
/// Place from which we are borrowing /// Place from which we are borrowing
pub borrowed_place: mir::Place<'tcx>, pub(crate) borrowed_place: mir::Place<'tcx>,
/// Place to which the borrow was stored /// Place to which the borrow was stored
pub assigned_place: mir::Place<'tcx>, pub(crate) assigned_place: mir::Place<'tcx>,
} }
impl<'tcx> fmt::Display for BorrowData<'tcx> { impl<'tcx> fmt::Display for BorrowData<'tcx> {
@ -120,7 +120,7 @@ impl LocalsStateAtExit {
} }
impl<'tcx> BorrowSet<'tcx> { impl<'tcx> BorrowSet<'tcx> {
pub fn build( pub(crate) fn build(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
body: &Body<'tcx>, body: &Body<'tcx>,
locals_are_invalidated_at_exit: bool, locals_are_invalidated_at_exit: bool,
@ -156,7 +156,7 @@ impl<'tcx> BorrowSet<'tcx> {
self.activation_map.get(&location).map_or(&[], |activations| &activations[..]) self.activation_map.get(&location).map_or(&[], |activations| &activations[..])
} }
pub fn len(&self) -> usize { pub(crate) fn len(&self) -> usize {
self.location_map.len() self.location_map.len()
} }

View File

@ -210,7 +210,7 @@ impl<'tcx> fmt::Debug for OutlivesConstraint<'tcx> {
rustc_index::newtype_index! { rustc_index::newtype_index! {
#[debug_format = "OutlivesConstraintIndex({})"] #[debug_format = "OutlivesConstraintIndex({})"]
pub struct OutlivesConstraintIndex {} pub(crate) struct OutlivesConstraintIndex {}
} }
rustc_index::newtype_index! { rustc_index::newtype_index! {

View File

@ -2733,7 +2733,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
/// cannot borrow `a.u` (via `a.u.z.c`) as immutable because it is also borrowed as /// cannot borrow `a.u` (via `a.u.z.c`) as immutable because it is also borrowed as
/// mutable (via `a.u.s.b`) [E0502] /// mutable (via `a.u.s.b`) [E0502]
/// ``` /// ```
pub(crate) fn describe_place_for_conflicting_borrow( fn describe_place_for_conflicting_borrow(
&self, &self,
first_borrowed_place: Place<'tcx>, first_borrowed_place: Place<'tcx>,
second_borrowed_place: Place<'tcx>, second_borrowed_place: Place<'tcx>,

View File

@ -55,7 +55,7 @@ use self::path_utils::*;
use self::prefixes::PrefixSet; use self::prefixes::PrefixSet;
use crate::session_diagnostics::VarNeedNotMut; use crate::session_diagnostics::VarNeedNotMut;
pub mod borrow_set; mod borrow_set;
mod borrowck_errors; mod borrowck_errors;
mod constraints; mod constraints;
mod dataflow; mod dataflow;
@ -434,7 +434,7 @@ fn do_mir_borrowck<'tcx>(
(result, body_with_facts) (result, body_with_facts)
} }
pub struct BorrowckInferCtxt<'tcx> { pub(crate) struct BorrowckInferCtxt<'tcx> {
pub(crate) infcx: InferCtxt<'tcx>, pub(crate) infcx: InferCtxt<'tcx>,
pub(crate) reg_var_to_origin: RefCell<FxIndexMap<ty::RegionVid, RegionCtxt>>, pub(crate) reg_var_to_origin: RefCell<FxIndexMap<ty::RegionVid, RegionCtxt>>,
} }

View File

@ -553,7 +553,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
} }
/// Returns an iterator over all the region indices. /// Returns an iterator over all the region indices.
pub fn regions(&self) -> impl Iterator<Item = RegionVid> + 'tcx { pub(crate) fn regions(&self) -> impl Iterator<Item = RegionVid> + 'tcx {
self.definitions.indices() self.definitions.indices()
} }
@ -561,12 +561,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
/// corresponding index. /// corresponding index.
/// ///
/// (Panics if `r` is not a registered universal region.) /// (Panics if `r` is not a registered universal region.)
pub fn to_region_vid(&self, r: ty::Region<'tcx>) -> RegionVid { pub(crate) fn to_region_vid(&self, r: ty::Region<'tcx>) -> RegionVid {
self.universal_regions.to_region_vid(r) self.universal_regions.to_region_vid(r)
} }
/// Returns an iterator over all the outlives constraints. /// Returns an iterator over all the outlives constraints.
pub fn outlives_constraints(&self) -> impl Iterator<Item = OutlivesConstraint<'tcx>> + '_ { pub(crate) fn outlives_constraints(
&self,
) -> impl Iterator<Item = OutlivesConstraint<'tcx>> + '_ {
self.constraints.outlives().iter().copied() self.constraints.outlives().iter().copied()
} }

View File

@ -15,7 +15,7 @@ use crate::BorrowIndex;
rustc_index::newtype_index! { rustc_index::newtype_index! {
/// A single integer representing a `ty::Placeholder`. /// A single integer representing a `ty::Placeholder`.
#[debug_format = "PlaceholderIndex({})"] #[debug_format = "PlaceholderIndex({})"]
pub struct PlaceholderIndex {} pub(crate) struct PlaceholderIndex {}
} }
/// An individual element in a region value -- the value of a /// An individual element in a region value -- the value of a