Skip to content

Commit 5486d72

Browse files
committed
Reduce visibilities.
Three of the modules don't need to be `pub`, and then `warn(unreachable_pub)` identifies a bunch more things that also shouldn't be `pub`, plus a couple of things that are unused.
1 parent 7a9bbd0 commit 5486d72

4 files changed

Lines changed: 25 additions & 52 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ use crate::traits::{self, ObligationCause, ObligationInspector, PredicateObligat
5656
pubmod at;
5757
pubmod canonical;
5858
mod context;
59-
pubmod free_regions;
59+
mod free_regions;
6060
mod freshen;
6161
mod lexical_region_resolve;
62-
pubmod opaque_types;
62+
mod opaque_types;
6363
pubmod outlives;
6464
mod projection;
6565
pubmod region_constraints;
6666
pubmod relate;
6767
pubmod resolve;
6868
pub(crate)mod snapshot;
69-
pubmod type_variable;
69+
mod type_variable;
7070

7171
#[must_use]
7272
#[derive(Debug)]

‎compiler/rustc_infer/src/infer/opaque_types/mod.rs‎

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use crate::traits::{self, Obligation};
1919

2020
mod table;
2121

22-
pubtypeOpaqueTypeMap<'tcx> = FxIndexMap<OpaqueTypeKey<'tcx>,OpaqueTypeDecl<'tcx>>;
23-
pubuse table::{OpaqueTypeStorage,OpaqueTypeTable};
22+
pub(crate)typeOpaqueTypeMap<'tcx> = FxIndexMap<OpaqueTypeKey<'tcx>,OpaqueTypeDecl<'tcx>>;
23+
pub(crate)use table::{OpaqueTypeStorage,OpaqueTypeTable};
2424

2525
usesuper::DefineOpaqueTypes;
2626

@@ -377,9 +377,9 @@ impl<'tcx> InferCtxt<'tcx> {
377377
///
378378
/// We ignore any type parameters because impl trait values are assumed to
379379
/// capture all the in-scope type parameters.
380-
pubstructConstrainOpaqueTypeRegionVisitor<'tcx,OP:FnMut(ty::Region<'tcx>)>{
381-
pubtcx:TyCtxt<'tcx>,
382-
pubop:OP,
380+
structConstrainOpaqueTypeRegionVisitor<'tcx,OP:FnMut(ty::Region<'tcx>)>{
381+
tcx:TyCtxt<'tcx>,
382+
op:OP,
383383
}
384384

385385
impl<'tcx,OP>TypeVisitor<TyCtxt<'tcx>>forConstrainOpaqueTypeRegionVisitor<'tcx,OP>
@@ -455,20 +455,6 @@ where
455455
}
456456
}
457457

458-
pubenumUseKind{
459-
DefiningUse,
460-
OpaqueUse,
461-
}
462-
463-
implUseKind{
464-
pubfnis_defining(self) -> bool{
465-
matchself{
466-
UseKind::DefiningUse => true,
467-
UseKind::OpaqueUse => false,
468-
}
469-
}
470-
}
471-
472458
impl<'tcx>InferCtxt<'tcx>{
473459
#[instrument(skip(self), level = "debug")]
474460
fnregister_hidden_type(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use super::{OpaqueTypeDecl, OpaqueTypeMap};
77
usecrate::infer::snapshot::undo_log::{InferCtxtUndoLogs,UndoLog};
88

99
#[derive(Default,Debug,Clone)]
10-
pubstructOpaqueTypeStorage<'tcx>{
10+
pub(crate)structOpaqueTypeStorage<'tcx>{
1111
/// Opaque types found in explicit return types and their
1212
/// associated fresh inference variable. Writeback resolves these
1313
/// variables to get the concrete type, which can be used to

‎compiler/rustc_infer/src/infer/type_variable.rs‎

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl<'tcx> Rollback<sv::UndoLog<ut::Delegate<TyVidEqKey<'tcx>>>> for TypeVariabl
2020
}
2121

2222
#[derive(Clone)]
23-
pubstructTypeVariableStorage<'tcx>{
23+
pub(crate)structTypeVariableStorage<'tcx>{
2424
/// The origins of each type variable.
2525
values:IndexVec<TyVid,TypeVariableData>,
2626
/// Two variables are unified in `eq_relations` when we have a
@@ -29,7 +29,7 @@ pub struct TypeVariableStorage<'tcx> {
2929
eq_relations: ut::UnificationTableStorage<TyVidEqKey<'tcx>>,
3030
}
3131

32-
pubstructTypeVariableTable<'a,'tcx>{
32+
pub(crate)structTypeVariableTable<'a,'tcx>{
3333
storage:&'amutTypeVariableStorage<'tcx>,
3434

3535
undo_log:&'amutInferCtxtUndoLogs<'tcx>,
@@ -50,22 +50,22 @@ pub(crate) struct TypeVariableData {
5050
}
5151

5252
#[derive(Copy,Clone,Debug)]
53-
pubenumTypeVariableValue<'tcx>{
53+
pub(crate)enumTypeVariableValue<'tcx>{
5454
Known{value:Ty<'tcx>},
5555
Unknown{universe: ty::UniverseIndex},
5656
}
5757

5858
impl<'tcx>TypeVariableValue<'tcx>{
5959
/// If this value is known, returns the type it is known to be.
6060
/// Otherwise, `None`.
61-
pubfnknown(&self) -> Option<Ty<'tcx>>{
61+
pub(crate)fnknown(&self) -> Option<Ty<'tcx>>{
6262
match*self{
6363
TypeVariableValue::Unknown{ .. } => None,
6464
TypeVariableValue::Known{ value } => Some(value),
6565
}
6666
}
6767

68-
pubfnis_unknown(&self) -> bool{
68+
pub(crate)fnis_unknown(&self) -> bool{
6969
match*self{
7070
TypeVariableValue::Unknown{ .. } => true,
7171
TypeVariableValue::Known{ .. } => false,
@@ -74,7 +74,7 @@ impl<'tcx> TypeVariableValue<'tcx> {
7474
}
7575

7676
impl<'tcx>TypeVariableStorage<'tcx>{
77-
pubfnnew() -> TypeVariableStorage<'tcx>{
77+
pub(crate)fnnew() -> TypeVariableStorage<'tcx>{
7878
TypeVariableStorage{
7979
values:Default::default(),
8080
eq_relations: ut::UnificationTableStorage::new(),
@@ -105,14 +105,14 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
105105
///
106106
/// Note that this function does not return care whether
107107
/// `vid` has been unified with something else or not.
108-
pubfnvar_origin(&self,vid: ty::TyVid) -> TypeVariableOrigin{
108+
pub(crate)fnvar_origin(&self,vid: ty::TyVid) -> TypeVariableOrigin{
109109
self.storage.values[vid].origin
110110
}
111111

112112
/// Records that `a == b`, depending on `dir`.
113113
///
114114
/// Precondition: neither `a` nor `b` are known.
115-
pubfnequate(&mutself,a: ty::TyVid,b: ty::TyVid){
115+
pub(crate)fnequate(&mutself,a: ty::TyVid,b: ty::TyVid){
116116
debug_assert!(self.probe(a).is_unknown());
117117
debug_assert!(self.probe(b).is_unknown());
118118
self.eq_relations().union(a, b);
@@ -121,7 +121,7 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
121121
/// Instantiates `vid` with the type `ty`.
122122
///
123123
/// Precondition: `vid` must not have been previously instantiated.
124-
pubfninstantiate(&mutself,vid: ty::TyVid,ty:Ty<'tcx>){
124+
pub(crate)fninstantiate(&mutself,vid: ty::TyVid,ty:Ty<'tcx>){
125125
let vid = self.root_var(vid);
126126
debug_assert!(!ty.is_ty_var(),"instantiating ty var with var: {vid:?} {ty:?}");
127127
debug_assert!(self.probe(vid).is_unknown());
@@ -143,7 +143,7 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
143143
/// - `origin`: indicates *why* the type variable was created.
144144
/// The code in this module doesn't care, but it can be useful
145145
/// for improving error messages.
146-
pubfnnew_var(
146+
pub(crate)fnnew_var(
147147
&mutself,
148148
universe: ty::UniverseIndex,
149149
origin:TypeVariableOrigin,
@@ -158,7 +158,7 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
158158
}
159159

160160
/// Returns the number of type variables created thus far.
161-
pubfnnum_vars(&self) -> usize{
161+
pub(crate)fnnum_vars(&self) -> usize{
162162
self.storage.values.len()
163163
}
164164

@@ -167,42 +167,29 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
167167
/// will yield the same root variable (per the union-find
168168
/// algorithm), so `root_var(a) == root_var(b)` implies that `a ==
169169
/// b` (transitively).
170-
pubfnroot_var(&mutself,vid: ty::TyVid) -> ty::TyVid{
170+
pub(crate)fnroot_var(&mutself,vid: ty::TyVid) -> ty::TyVid{
171171
self.eq_relations().find(vid).vid
172172
}
173173

174174
/// Retrieves the type to which `vid` has been instantiated, if
175175
/// any.
176-
pubfnprobe(&mutself,vid: ty::TyVid) -> TypeVariableValue<'tcx>{
176+
pub(crate)fnprobe(&mutself,vid: ty::TyVid) -> TypeVariableValue<'tcx>{
177177
self.inlined_probe(vid)
178178
}
179179

180180
/// An always-inlined variant of `probe`, for very hot call sites.
181181
#[inline(always)]
182-
pubfninlined_probe(&mutself,vid: ty::TyVid) -> TypeVariableValue<'tcx>{
182+
pub(crate)fninlined_probe(&mutself,vid: ty::TyVid) -> TypeVariableValue<'tcx>{
183183
self.eq_relations().inlined_probe_value(vid)
184184
}
185185

186-
/// If `t` is a type-inference variable, and it has been
187-
/// instantiated, then return the with which it was
188-
/// instantiated. Otherwise, returns `t`.
189-
pubfnreplace_if_possible(&mutself,t:Ty<'tcx>) -> Ty<'tcx>{
190-
match*t.kind(){
191-
ty::Infer(ty::TyVar(v)) => matchself.probe(v){
192-
TypeVariableValue::Unknown{ .. } => t,
193-
TypeVariableValue::Known{ value } => value,
194-
},
195-
_ => t,
196-
}
197-
}
198-
199186
#[inline]
200187
fneq_relations(&mutself) -> super::UnificationTable<'_,'tcx,TyVidEqKey<'tcx>>{
201188
self.storage.eq_relations.with_log(self.undo_log)
202189
}
203190

204191
/// Returns a range of the type variables created during the snapshot.
205-
pubfnvars_since_snapshot(
192+
pub(crate)fnvars_since_snapshot(
206193
&mutself,
207194
value_count:usize,
208195
) -> (Range<TyVid>,Vec<TypeVariableOrigin>){
@@ -215,7 +202,7 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
215202

216203
/// Returns indices of all variables that are not yet
217204
/// instantiated.
218-
pubfnunresolved_variables(&mutself) -> Vec<ty::TyVid>{
205+
pub(crate)fnunresolved_variables(&mutself) -> Vec<ty::TyVid>{
219206
(0..self.num_vars())
220207
.filter_map(|i| {
221208
let vid = ty::TyVid::from_usize(i);

0 commit comments

Comments
 (0)