Reduce visibilities some more.

It helps people reading the code understand how widely things are used.
This commit is contained in:
Nicholas Nethercote 2024-10-01 16:40:22 +10:00
parent 5c015eed47
commit 2d2755ff97
9 changed files with 26 additions and 25 deletions

View File

@ -14,7 +14,8 @@
GenericKind, RegionConstraintCollector, RegionConstraintStorage, VarInfos, VerifyBound,
};
pub use relate::StructurallyRelateAliases;
pub use relate::combine::{CombineFields, PredicateEmittingRelation};
use relate::combine::CombineFields;
pub use relate::combine::PredicateEmittingRelation;
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
use rustc_data_structures::sync::Lrc;
@ -75,7 +76,7 @@ pub struct InferOk<'tcx, T> {
}
pub type InferResult<'tcx, T> = Result<InferOk<'tcx, T>, TypeError<'tcx>>;
pub type FixupResult<T> = Result<T, FixupError>; // "fixup result"
pub(crate) type FixupResult<T> = Result<T, FixupError>; // "fixup result"
pub(crate) type UnificationTable<'a, 'tcx, T> = ut::UnificationTable<
ut::InPlace<T, &'a mut ut::UnificationStorage<T>, &'a mut InferCtxtUndoLogs<'tcx>>,
@ -200,7 +201,7 @@ fn type_variables(&mut self) -> type_variable::TypeVariableTable<'_, 'tcx> {
}
#[inline]
pub fn opaque_types(&mut self) -> opaque_types::OpaqueTypeTable<'_, 'tcx> {
fn opaque_types(&mut self) -> opaque_types::OpaqueTypeTable<'_, 'tcx> {
self.opaque_type_storage.with_log(&mut self.undo_log)
}
@ -1351,7 +1352,7 @@ fn replace_const(&mut self, bv: ty::BoundVar) -> ty::Const<'tcx> {
}
/// See the [`region_constraints::RegionConstraintCollector::verify_generic_bound`] method.
pub fn verify_generic_bound(
pub(crate) fn verify_generic_bound(
&self,
origin: SubregionOrigin<'tcx>,
kind: GenericKind<'tcx>,

View File

@ -46,7 +46,7 @@ fn drop(&mut self) {
}
}
pub struct OpaqueTypeTable<'a, 'tcx> {
pub(crate) struct OpaqueTypeTable<'a, 'tcx> {
storage: &'a mut OpaqueTypeStorage<'tcx>,
undo_log: &'a mut InferCtxtUndoLogs<'tcx>,

View File

@ -14,7 +14,7 @@
pub mod for_liveness;
pub mod obligations;
pub mod test_type_match;
pub mod verify;
pub(crate) mod verify;
#[instrument(level = "debug", skip(param_env), ret)]
pub fn explicit_outlives_bounds<'tcx>(

View File

@ -15,7 +15,7 @@
/// via a "delegate" of type `D` -- this is usually the `infcx`, which
/// accrues them into the `region_obligations` code, but for NLL we
/// use something else.
pub struct VerifyBoundCx<'cx, 'tcx> {
pub(crate) struct VerifyBoundCx<'cx, 'tcx> {
tcx: TyCtxt<'tcx>,
region_bound_pairs: &'cx RegionBoundPairs<'tcx>,
/// During borrowck, if there are no outlives bounds on a generic
@ -28,7 +28,7 @@ pub struct VerifyBoundCx<'cx, 'tcx> {
}
impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
pub fn new(
pub(crate) fn new(
tcx: TyCtxt<'tcx>,
region_bound_pairs: &'cx RegionBoundPairs<'tcx>,
implicit_region_bound: Option<ty::Region<'tcx>>,
@ -38,7 +38,7 @@ pub fn new(
}
#[instrument(level = "debug", skip(self))]
pub fn param_or_placeholder_bound(&self, ty: Ty<'tcx>) -> VerifyBound<'tcx> {
pub(crate) fn param_or_placeholder_bound(&self, ty: Ty<'tcx>) -> VerifyBound<'tcx> {
// Start with anything like `T: 'a` we can scrape from the
// environment. If the environment contains something like
// `for<'a> T: 'a`, then we know that `T` outlives everything.
@ -92,7 +92,7 @@ pub fn param_or_placeholder_bound(&self, ty: Ty<'tcx>) -> VerifyBound<'tcx> {
/// the clause from the environment only applies if `'0 = 'a`,
/// which we don't know yet. But we would still include `'b` in
/// this list.
pub fn approx_declared_bounds_from_env(
pub(crate) fn approx_declared_bounds_from_env(
&self,
alias_ty: ty::AliasTy<'tcx>,
) -> Vec<ty::PolyTypeOutlivesPredicate<'tcx>> {
@ -101,7 +101,7 @@ pub fn approx_declared_bounds_from_env(
}
#[instrument(level = "debug", skip(self))]
pub fn alias_bound(&self, alias_ty: ty::AliasTy<'tcx>) -> VerifyBound<'tcx> {
pub(crate) fn alias_bound(&self, alias_ty: ty::AliasTy<'tcx>) -> VerifyBound<'tcx> {
let alias_ty_as_ty = alias_ty.to_ty(self.tcx);
// Search the env for where clauses like `P: 'a`.
@ -285,7 +285,7 @@ fn declared_generic_bounds_from_env_for_erased_ty(
///
/// This is for simplicity, and because we are not really smart
/// enough to cope with such bounds anywhere.
pub fn declared_bounds_from_definition(
pub(crate) fn declared_bounds_from_definition(
&self,
alias_ty: ty::AliasTy<'tcx>,
) -> impl Iterator<Item = ty::Region<'tcx>> {

View File

@ -304,7 +304,7 @@ pub struct RegionVariableInfo {
pub universe: ty::UniverseIndex,
}
pub struct RegionSnapshot {
pub(crate) struct RegionSnapshot {
any_unifications: bool,
}

View File

@ -33,7 +33,7 @@
use crate::traits::{Obligation, PredicateObligation};
#[derive(Clone)]
pub struct CombineFields<'infcx, 'tcx> {
pub(crate) struct CombineFields<'infcx, 'tcx> {
pub infcx: &'infcx InferCtxt<'tcx>,
// Immutable fields
pub trace: TypeTrace<'tcx>,
@ -47,7 +47,7 @@ pub struct CombineFields<'infcx, 'tcx> {
}
impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
pub fn new(
pub(crate) fn new(
infcx: &'infcx InferCtxt<'tcx>,
trace: TypeTrace<'tcx>,
param_env: ty::ParamEnv<'tcx>,
@ -283,22 +283,22 @@ fn unify_effect_variable(&self, vid: ty::EffectVid, val: ty::Const<'tcx>) -> ty:
}
impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
pub fn tcx(&self) -> TyCtxt<'tcx> {
pub(crate) fn tcx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx
}
pub fn equate<'a>(
pub(crate) fn equate<'a>(
&'a mut self,
structurally_relate_aliases: StructurallyRelateAliases,
) -> TypeRelating<'a, 'infcx, 'tcx> {
TypeRelating::new(self, structurally_relate_aliases, ty::Invariant)
}
pub fn sub<'a>(&'a mut self) -> TypeRelating<'a, 'infcx, 'tcx> {
pub(crate) fn sub<'a>(&'a mut self) -> TypeRelating<'a, 'infcx, 'tcx> {
TypeRelating::new(self, StructurallyRelateAliases::No, ty::Covariant)
}
pub fn sup<'a>(&'a mut self) -> TypeRelating<'a, 'infcx, 'tcx> {
pub(crate) fn sup<'a>(&'a mut self) -> TypeRelating<'a, 'infcx, 'tcx> {
TypeRelating::new(self, StructurallyRelateAliases::No, ty::Contravariant)
}
@ -310,14 +310,14 @@ pub(crate) fn glb<'a>(&'a mut self) -> LatticeOp<'a, 'infcx, 'tcx> {
LatticeOp::new(self, LatticeOpKind::Glb)
}
pub fn register_obligations(
pub(crate) fn register_obligations(
&mut self,
obligations: impl IntoIterator<Item = Goal<'tcx, ty::Predicate<'tcx>>>,
) {
self.goals.extend(obligations);
}
pub fn register_predicates(
pub(crate) fn register_predicates(
&mut self,
obligations: impl IntoIterator<Item: Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>>>,
) {

View File

@ -5,7 +5,7 @@
pub use rustc_middle::ty::relate::RelateResult;
pub use rustc_next_trait_solver::relate::*;
pub use self::combine::{CombineFields, PredicateEmittingRelation};
pub use self::combine::PredicateEmittingRelation;
#[allow(hidden_glob_reexports)]
pub(super) mod combine;

View File

@ -13,7 +13,7 @@
use crate::infer::{DefineOpaqueTypes, InferCtxt, SubregionOrigin};
/// Enforce that `a` is equal to or a subtype of `b`.
pub struct TypeRelating<'combine, 'a, 'tcx> {
pub(crate) struct TypeRelating<'combine, 'a, 'tcx> {
// Immutable except for the `InferCtxt` and the
// resulting nested `goals`.
fields: &'combine mut CombineFields<'a, 'tcx>,
@ -49,7 +49,7 @@ pub struct TypeRelating<'combine, 'a, 'tcx> {
}
impl<'combine, 'infcx, 'tcx> TypeRelating<'combine, 'infcx, 'tcx> {
pub fn new(
pub(crate) fn new(
f: &'combine mut CombineFields<'infcx, 'tcx>,
structurally_relate_aliases: StructurallyRelateAliases,
ambient_variance: ty::Variance,

View File

@ -5,7 +5,7 @@
use super::InferCtxt;
use super::region_constraints::RegionSnapshot;
mod fudge;
pub(crate) mod fudge;
pub(crate) mod undo_log;
use undo_log::{Snapshot, UndoLog};