Skip to content

Commit

Permalink
Reduce visibilities.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Nov 4, 2024
1 parent e3a918e commit 6676cec
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
26 changes: 13 additions & 13 deletions compiler/rustc_borrowck/src/borrow_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand All @@ -45,7 +45,7 @@ impl<'tcx> Index<BorrowIndex> for BorrowSet<'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),
Expand All @@ -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> {
Expand Down Expand Up @@ -120,7 +120,7 @@ impl LocalsStateAtExit {
}

impl<'tcx> BorrowSet<'tcx> {
pub fn build(
pub(crate) fn build(
tcx: TyCtxt<'tcx>,
body: &Body<'tcx>,
locals_are_invalidated_at_exit: bool,
Expand Down Expand Up @@ -156,7 +156,7 @@ impl<'tcx> BorrowSet<'tcx> {
self.activation_map.get(&location).map_or(&[], |activations| &activations[..])
}

pub fn len(&self) -> usize {
pub(crate) fn len(&self) -> usize {
self.location_map.len()
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/constraints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl<'tcx> fmt::Debug for OutlivesConstraint<'tcx> {

rustc_index::newtype_index! {
#[debug_format = "OutlivesConstraintIndex({})"]
pub struct OutlivesConstraintIndex {}
pub(crate) struct OutlivesConstraintIndex {}
}

rustc_index::newtype_index! {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
/// 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>,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use self::path_utils::*;
use self::prefixes::PrefixSet;
use crate::session_diagnostics::VarNeedNotMut;

pub mod borrow_set;
mod borrow_set;
mod borrowck_errors;
mod constraints;
mod dataflow;
Expand Down Expand Up @@ -434,7 +434,7 @@ fn do_mir_borrowck<'tcx>(
(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>>,
}
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,20 +553,22 @@ impl<'tcx> RegionInferenceContext<'tcx> {
}

/// 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()
}

/// Given a universal region in scope on the MIR, returns the
/// 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()
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/region_infer/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::BorrowIndex;
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
Expand Down

0 comments on commit 6676cec

Please sign in to comment.