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
/// appears on the right hand side. Thus the location is the map
/// 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.
/// 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
/// 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.
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> {
@ -45,7 +45,7 @@ fn index(&self, index: BorrowIndex) -> &BorrowData<'tcx> {
/// Location where a two-phase borrow is activated, if a borrow
/// is in fact a two-phase borrow.
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum TwoPhaseActivation {
pub(crate) enum TwoPhaseActivation {
NotTwoPhase,
NotActivated,
ActivatedAt(Location),
@ -55,17 +55,17 @@ pub enum TwoPhaseActivation {
pub struct BorrowData<'tcx> {
/// Location where the borrow reservation starts.
/// 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.
pub activation_location: TwoPhaseActivation,
pub(crate) activation_location: TwoPhaseActivation,
/// What kind of borrow this is
pub kind: mir::BorrowKind,
pub(crate) kind: mir::BorrowKind,
/// The region for which this borrow is live
pub region: RegionVid,
pub(crate) region: RegionVid,
/// 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
pub assigned_place: mir::Place<'tcx>,
pub(crate) assigned_place: mir::Place<'tcx>,
}
impl<'tcx> fmt::Display for BorrowData<'tcx> {
@ -120,7 +120,7 @@ fn visit_local(&mut self, local: Local, ctx: PlaceContext, _: Location) {
}
impl<'tcx> BorrowSet<'tcx> {
pub fn build(
pub(crate) fn build(
tcx: TyCtxt<'tcx>,
body: &Body<'tcx>,
locals_are_invalidated_at_exit: bool,
@ -156,7 +156,7 @@ pub(crate) fn activations_at_location(&self, location: Location) -> &[BorrowInde
self.activation_map.get(&location).map_or(&[], |activations| &activations[..])
}
pub fn len(&self) -> usize {
pub(crate) fn len(&self) -> usize {
self.location_map.len()
}

View File

@ -210,7 +210,7 @@ fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
rustc_index::newtype_index! {
#[debug_format = "OutlivesConstraintIndex({})"]
pub struct OutlivesConstraintIndex {}
pub(crate) struct OutlivesConstraintIndex {}
}
rustc_index::newtype_index! {

View File

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

View File

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

View File

@ -553,7 +553,7 @@ fn init_free_and_bound_regions(&mut self) {
}
/// 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()
}
@ -561,12 +561,14 @@ pub fn regions(&self) -> impl Iterator<Item = RegionVid> + 'tcx {
/// corresponding index.
///
/// (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)
}
/// 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()
}

View File

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