Skip to content

Commit 2d2755f

Browse files
committed
Reduce visibilities some more.
It helps people reading the code understand how widely things are used.
1 parent 5c015ee commit 2d2755f

File tree

9 files changed

+26
-25
lines changed

9 files changed

+26
-25
lines changed

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ use region_constraints::{
1414
GenericKind, RegionConstraintCollector, RegionConstraintStorage, VarInfos, VerifyBound,
1515
};
1616
pub use relate::StructurallyRelateAliases;
17-
pub use relate::combine::{CombineFields, PredicateEmittingRelation};
17+
use relate::combine::CombineFields;
18+
pub use relate::combine::PredicateEmittingRelation;
1819
use rustc_data_structures::captures::Captures;
1920
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
2021
use rustc_data_structures::sync::Lrc;
@@ -75,7 +76,7 @@ pub struct InferOk<'tcx, T> {
7576
}
7677
pub type InferResult<'tcx, T> = Result<InferOk<'tcx, T>, TypeError<'tcx>>;
7778

78-
pub type FixupResult<T> = Result<T, FixupError>; // "fixup result"
79+
pub(crate) type FixupResult<T> = Result<T, FixupError>; // "fixup result"
7980

8081
pub(crate) type UnificationTable<'a, 'tcx, T> = ut::UnificationTable<
8182
ut::InPlace<T, &'a mut ut::UnificationStorage<T>, &'a mut InferCtxtUndoLogs<'tcx>>,
@@ -200,7 +201,7 @@ impl<'tcx> InferCtxtInner<'tcx> {
200201
}
201202

202203
#[inline]
203-
pub fn opaque_types(&mut self) -> opaque_types::OpaqueTypeTable<'_, 'tcx> {
204+
fn opaque_types(&mut self) -> opaque_types::OpaqueTypeTable<'_, 'tcx> {
204205
self.opaque_type_storage.with_log(&mut self.undo_log)
205206
}
206207

@@ -1351,7 +1352,7 @@ impl<'tcx> InferCtxt<'tcx> {
13511352
}
13521353

13531354
/// See the [`region_constraints::RegionConstraintCollector::verify_generic_bound`] method.
1354-
pub fn verify_generic_bound(
1355+
pub(crate) fn verify_generic_bound(
13551356
&self,
13561357
origin: SubregionOrigin<'tcx>,
13571358
kind: GenericKind<'tcx>,

compiler/rustc_infer/src/infer/opaque_types/table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<'tcx> Drop for OpaqueTypeStorage<'tcx> {
4646
}
4747
}
4848

49-
pub struct OpaqueTypeTable<'a, 'tcx> {
49+
pub(crate) struct OpaqueTypeTable<'a, 'tcx> {
5050
storage: &'a mut OpaqueTypeStorage<'tcx>,
5151

5252
undo_log: &'a mut InferCtxtUndoLogs<'tcx>,

compiler/rustc_infer/src/infer/outlives/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub mod env;
1414
pub mod for_liveness;
1515
pub mod obligations;
1616
pub mod test_type_match;
17-
pub mod verify;
17+
pub(crate) mod verify;
1818

1919
#[instrument(level = "debug", skip(param_env), ret)]
2020
pub fn explicit_outlives_bounds<'tcx>(

compiler/rustc_infer/src/infer/outlives/verify.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::infer::{GenericKind, VerifyBound};
1515
/// via a "delegate" of type `D` -- this is usually the `infcx`, which
1616
/// accrues them into the `region_obligations` code, but for NLL we
1717
/// use something else.
18-
pub struct VerifyBoundCx<'cx, 'tcx> {
18+
pub(crate) struct VerifyBoundCx<'cx, 'tcx> {
1919
tcx: TyCtxt<'tcx>,
2020
region_bound_pairs: &'cx RegionBoundPairs<'tcx>,
2121
/// During borrowck, if there are no outlives bounds on a generic
@@ -28,7 +28,7 @@ pub struct VerifyBoundCx<'cx, 'tcx> {
2828
}
2929

3030
impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
31-
pub fn new(
31+
pub(crate) fn new(
3232
tcx: TyCtxt<'tcx>,
3333
region_bound_pairs: &'cx RegionBoundPairs<'tcx>,
3434
implicit_region_bound: Option<ty::Region<'tcx>>,
@@ -38,7 +38,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
3838
}
3939

4040
#[instrument(level = "debug", skip(self))]
41-
pub fn param_or_placeholder_bound(&self, ty: Ty<'tcx>) -> VerifyBound<'tcx> {
41+
pub(crate) fn param_or_placeholder_bound(&self, ty: Ty<'tcx>) -> VerifyBound<'tcx> {
4242
// Start with anything like `T: 'a` we can scrape from the
4343
// environment. If the environment contains something like
4444
// `for<'a> T: 'a`, then we know that `T` outlives everything.
@@ -92,7 +92,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
9292
/// the clause from the environment only applies if `'0 = 'a`,
9393
/// which we don't know yet. But we would still include `'b` in
9494
/// this list.
95-
pub fn approx_declared_bounds_from_env(
95+
pub(crate) fn approx_declared_bounds_from_env(
9696
&self,
9797
alias_ty: ty::AliasTy<'tcx>,
9898
) -> Vec<ty::PolyTypeOutlivesPredicate<'tcx>> {
@@ -101,7 +101,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
101101
}
102102

103103
#[instrument(level = "debug", skip(self))]
104-
pub fn alias_bound(&self, alias_ty: ty::AliasTy<'tcx>) -> VerifyBound<'tcx> {
104+
pub(crate) fn alias_bound(&self, alias_ty: ty::AliasTy<'tcx>) -> VerifyBound<'tcx> {
105105
let alias_ty_as_ty = alias_ty.to_ty(self.tcx);
106106

107107
// Search the env for where clauses like `P: 'a`.
@@ -285,7 +285,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
285285
///
286286
/// This is for simplicity, and because we are not really smart
287287
/// enough to cope with such bounds anywhere.
288-
pub fn declared_bounds_from_definition(
288+
pub(crate) fn declared_bounds_from_definition(
289289
&self,
290290
alias_ty: ty::AliasTy<'tcx>,
291291
) -> impl Iterator<Item = ty::Region<'tcx>> {

compiler/rustc_infer/src/infer/region_constraints/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ pub struct RegionVariableInfo {
304304
pub universe: ty::UniverseIndex,
305305
}
306306

307-
pub struct RegionSnapshot {
307+
pub(crate) struct RegionSnapshot {
308308
any_unifications: bool,
309309
}
310310

compiler/rustc_infer/src/infer/relate/combine.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use crate::infer::{DefineOpaqueTypes, InferCtxt, TypeTrace, relate};
3333
use crate::traits::{Obligation, PredicateObligation};
3434

3535
#[derive(Clone)]
36-
pub struct CombineFields<'infcx, 'tcx> {
36+
pub(crate) struct CombineFields<'infcx, 'tcx> {
3737
pub infcx: &'infcx InferCtxt<'tcx>,
3838
// Immutable fields
3939
pub trace: TypeTrace<'tcx>,
@@ -47,7 +47,7 @@ pub struct CombineFields<'infcx, 'tcx> {
4747
}
4848

4949
impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
50-
pub fn new(
50+
pub(crate) fn new(
5151
infcx: &'infcx InferCtxt<'tcx>,
5252
trace: TypeTrace<'tcx>,
5353
param_env: ty::ParamEnv<'tcx>,
@@ -283,22 +283,22 @@ impl<'tcx> InferCtxt<'tcx> {
283283
}
284284

285285
impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
286-
pub fn tcx(&self) -> TyCtxt<'tcx> {
286+
pub(crate) fn tcx(&self) -> TyCtxt<'tcx> {
287287
self.infcx.tcx
288288
}
289289

290-
pub fn equate<'a>(
290+
pub(crate) fn equate<'a>(
291291
&'a mut self,
292292
structurally_relate_aliases: StructurallyRelateAliases,
293293
) -> TypeRelating<'a, 'infcx, 'tcx> {
294294
TypeRelating::new(self, structurally_relate_aliases, ty::Invariant)
295295
}
296296

297-
pub fn sub<'a>(&'a mut self) -> TypeRelating<'a, 'infcx, 'tcx> {
297+
pub(crate) fn sub<'a>(&'a mut self) -> TypeRelating<'a, 'infcx, 'tcx> {
298298
TypeRelating::new(self, StructurallyRelateAliases::No, ty::Covariant)
299299
}
300300

301-
pub fn sup<'a>(&'a mut self) -> TypeRelating<'a, 'infcx, 'tcx> {
301+
pub(crate) fn sup<'a>(&'a mut self) -> TypeRelating<'a, 'infcx, 'tcx> {
302302
TypeRelating::new(self, StructurallyRelateAliases::No, ty::Contravariant)
303303
}
304304

@@ -310,14 +310,14 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
310310
LatticeOp::new(self, LatticeOpKind::Glb)
311311
}
312312

313-
pub fn register_obligations(
313+
pub(crate) fn register_obligations(
314314
&mut self,
315315
obligations: impl IntoIterator<Item = Goal<'tcx, ty::Predicate<'tcx>>>,
316316
) {
317317
self.goals.extend(obligations);
318318
}
319319

320-
pub fn register_predicates(
320+
pub(crate) fn register_predicates(
321321
&mut self,
322322
obligations: impl IntoIterator<Item: Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>>>,
323323
) {

compiler/rustc_infer/src/infer/relate/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
pub use rustc_middle::ty::relate::RelateResult;
66
pub use rustc_next_trait_solver::relate::*;
77

8-
pub use self::combine::{CombineFields, PredicateEmittingRelation};
8+
pub use self::combine::PredicateEmittingRelation;
99

1010
#[allow(hidden_glob_reexports)]
1111
pub(super) mod combine;

compiler/rustc_infer/src/infer/relate/type_relating.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::infer::relate::{PredicateEmittingRelation, StructurallyRelateAliases}
1313
use crate::infer::{DefineOpaqueTypes, InferCtxt, SubregionOrigin};
1414

1515
/// Enforce that `a` is equal to or a subtype of `b`.
16-
pub struct TypeRelating<'combine, 'a, 'tcx> {
16+
pub(crate) struct TypeRelating<'combine, 'a, 'tcx> {
1717
// Immutable except for the `InferCtxt` and the
1818
// resulting nested `goals`.
1919
fields: &'combine mut CombineFields<'a, 'tcx>,
@@ -49,7 +49,7 @@ pub struct TypeRelating<'combine, 'a, 'tcx> {
4949
}
5050

5151
impl<'combine, 'infcx, 'tcx> TypeRelating<'combine, 'infcx, 'tcx> {
52-
pub fn new(
52+
pub(crate) fn new(
5353
f: &'combine mut CombineFields<'infcx, 'tcx>,
5454
structurally_relate_aliases: StructurallyRelateAliases,
5555
ambient_variance: ty::Variance,

compiler/rustc_infer/src/infer/snapshot/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use tracing::{debug, instrument};
55
use super::InferCtxt;
66
use super::region_constraints::RegionSnapshot;
77

8-
mod fudge;
8+
pub(crate) mod fudge;
99
pub(crate) mod undo_log;
1010

1111
use undo_log::{Snapshot, UndoLog};

0 commit comments

Comments
 (0)