Skip to content

Commit 5d6c539

Browse files
committed
Fix item visibilities
1 parent de3f983 commit 5d6c539

File tree

3 files changed

+27
-31
lines changed

3 files changed

+27
-31
lines changed

compiler/rustc_pattern_analysis/src/constructor.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ pub struct IntRange {
253253

254254
impl IntRange {
255255
/// Best effort; will not know that e.g. `255u8..` is a singleton.
256-
pub fn is_singleton(&self) -> bool {
256+
pub(crate) fn is_singleton(&self) -> bool {
257257
// Since `lo` and `hi` can't be the same `Infinity` and `plus_one` never changes from finite
258258
// to infinite, this correctly only detects ranges that contain exacly one `Finite(x)`.
259259
self.lo.plus_one() == self.hi
@@ -670,11 +670,11 @@ pub enum Constructor<'tcx> {
670670
}
671671

672672
impl<'tcx> Constructor<'tcx> {
673-
pub(super) fn is_non_exhaustive(&self) -> bool {
673+
pub(crate) fn is_non_exhaustive(&self) -> bool {
674674
matches!(self, NonExhaustive)
675675
}
676676

677-
pub(super) fn as_variant(&self) -> Option<VariantIdx> {
677+
pub(crate) fn as_variant(&self) -> Option<VariantIdx> {
678678
match self {
679679
Variant(i) => Some(*i),
680680
_ => None,
@@ -686,7 +686,7 @@ impl<'tcx> Constructor<'tcx> {
686686
_ => None,
687687
}
688688
}
689-
pub(super) fn as_int_range(&self) -> Option<&IntRange> {
689+
pub(crate) fn as_int_range(&self) -> Option<&IntRange> {
690690
match self {
691691
IntRange(range) => Some(range),
692692
_ => None,
@@ -830,10 +830,10 @@ pub enum ConstructorSet {
830830
/// of the `ConstructorSet` for the type, yet if we forgot to include them in `present` we would be
831831
/// ignoring any row with `Opaque`s in the algorithm. Hence the importance of point 4.
832832
#[derive(Debug)]
833-
pub(super) struct SplitConstructorSet<'tcx> {
834-
pub(super) present: SmallVec<[Constructor<'tcx>; 1]>,
835-
pub(super) missing: Vec<Constructor<'tcx>>,
836-
pub(super) missing_empty: Vec<Constructor<'tcx>>,
833+
pub(crate) struct SplitConstructorSet<'tcx> {
834+
pub(crate) present: SmallVec<[Constructor<'tcx>; 1]>,
835+
pub(crate) missing: Vec<Constructor<'tcx>>,
836+
pub(crate) missing_empty: Vec<Constructor<'tcx>>,
837837
}
838838

839839
impl ConstructorSet {
@@ -842,7 +842,7 @@ impl ConstructorSet {
842842
/// or slices. This can get subtle; see [`SplitConstructorSet`] for details of this operation
843843
/// and its invariants.
844844
#[instrument(level = "debug", skip(self, pcx, ctors), ret)]
845-
pub(super) fn split<'a, 'tcx>(
845+
pub(crate) fn split<'a, 'tcx>(
846846
&self,
847847
pcx: &PatCtxt<'_, '_, 'tcx>,
848848
ctors: impl Iterator<Item = &'a Constructor<'tcx>> + Clone,

compiler/rustc_pattern_analysis/src/pat.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ pub struct DeconstructedPat<'p, 'tcx> {
3737
}
3838

3939
impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
40-
pub(super) fn wildcard(ty: Ty<'tcx>, span: Span) -> Self {
40+
pub fn wildcard(ty: Ty<'tcx>, span: Span) -> Self {
4141
Self::new(Wildcard, &[], ty, span)
4242
}
4343

44-
pub(super) fn new(
44+
pub fn new(
4545
ctor: Constructor<'tcx>,
4646
fields: &'p [DeconstructedPat<'p, 'tcx>],
4747
ty: Ty<'tcx>,
@@ -50,11 +50,11 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
5050
DeconstructedPat { ctor, fields, ty, span, useful: Cell::new(false) }
5151
}
5252

53-
pub(super) fn is_or_pat(&self) -> bool {
53+
pub(crate) fn is_or_pat(&self) -> bool {
5454
matches!(self.ctor, Or)
5555
}
5656
/// Expand this (possibly-nested) or-pattern into its alternatives.
57-
pub(super) fn flatten_or_pat(&'p self) -> SmallVec<[&'p Self; 1]> {
57+
pub(crate) fn flatten_or_pat(&'p self) -> SmallVec<[&'p Self; 1]> {
5858
if self.is_or_pat() {
5959
self.iter_fields().flat_map(|p| p.flatten_or_pat()).collect()
6060
} else {
@@ -80,7 +80,7 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
8080

8181
/// Specialize this pattern with a constructor.
8282
/// `other_ctor` can be different from `self.ctor`, but must be covered by it.
83-
pub(super) fn specialize<'a>(
83+
pub(crate) fn specialize<'a>(
8484
&'a self,
8585
pcx: &PatCtxt<'_, 'p, 'tcx>,
8686
other_ctor: &Constructor<'tcx>,
@@ -122,10 +122,10 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
122122

123123
/// We keep track for each pattern if it was ever useful during the analysis. This is used
124124
/// with `redundant_spans` to report redundant subpatterns arising from or patterns.
125-
pub(super) fn set_useful(&self) {
125+
pub(crate) fn set_useful(&self) {
126126
self.useful.set(true)
127127
}
128-
pub(super) fn is_useful(&self) -> bool {
128+
pub(crate) fn is_useful(&self) -> bool {
129129
if self.useful.get() {
130130
true
131131
} else if self.is_or_pat() && self.iter_fields().any(|f| f.is_useful()) {
@@ -140,7 +140,7 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
140140
}
141141

142142
/// Report the spans of subpatterns that were not useful, if any.
143-
pub(super) fn redundant_spans(&self) -> Vec<Span> {
143+
pub(crate) fn redundant_spans(&self) -> Vec<Span> {
144144
let mut spans = Vec::new();
145145
self.collect_redundant_spans(&mut spans);
146146
spans
@@ -175,17 +175,17 @@ pub struct WitnessPat<'tcx> {
175175
}
176176

177177
impl<'tcx> WitnessPat<'tcx> {
178-
pub(super) fn new(ctor: Constructor<'tcx>, fields: Vec<Self>, ty: Ty<'tcx>) -> Self {
178+
pub(crate) fn new(ctor: Constructor<'tcx>, fields: Vec<Self>, ty: Ty<'tcx>) -> Self {
179179
Self { ctor, fields, ty }
180180
}
181-
pub(super) fn wildcard(ty: Ty<'tcx>) -> Self {
181+
pub(crate) fn wildcard(ty: Ty<'tcx>) -> Self {
182182
Self::new(Wildcard, Vec::new(), ty)
183183
}
184184

185185
/// Construct a pattern that matches everything that starts with this constructor.
186186
/// For example, if `ctor` is a `Constructor::Variant` for `Option::Some`, we get the pattern
187187
/// `Some(_)`.
188-
pub(super) fn wild_from_ctor(pcx: &PatCtxt<'_, '_, 'tcx>, ctor: Constructor<'tcx>) -> Self {
188+
pub(crate) fn wild_from_ctor(pcx: &PatCtxt<'_, '_, 'tcx>, ctor: Constructor<'tcx>) -> Self {
189189
let field_tys =
190190
pcx.cx.ctor_wildcard_fields(&ctor, pcx.ty).iter().map(|deco_pat| deco_pat.ty());
191191
let fields = field_tys.map(|ty| Self::wildcard(ty)).collect();

compiler/rustc_pattern_analysis/src/usefulness.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ impl<'a, 'p, 'tcx> fmt::Debug for PatCtxt<'a, 'p, 'tcx> {
594594
/// - in the matrix, track whether a given place (aka column) is known to contain a valid value or
595595
/// not.
596596
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
597-
pub(super) enum ValidityConstraint {
597+
enum ValidityConstraint {
598598
ValidOnly,
599599
MaybeInvalid,
600600
/// Option for backwards compatibility: the place is not known to be valid but we allow omitting
@@ -603,7 +603,7 @@ pub(super) enum ValidityConstraint {
603603
}
604604

605605
impl ValidityConstraint {
606-
pub(super) fn from_bool(is_valid_only: bool) -> Self {
606+
fn from_bool(is_valid_only: bool) -> Self {
607607
if is_valid_only { ValidOnly } else { MaybeInvalid }
608608
}
609609

@@ -615,10 +615,10 @@ impl ValidityConstraint {
615615
}
616616
}
617617

618-
pub(super) fn is_known_valid(self) -> bool {
618+
fn is_known_valid(self) -> bool {
619619
matches!(self, ValidOnly)
620620
}
621-
pub(super) fn allows_omitting_empty_arms(self) -> bool {
621+
fn allows_omitting_empty_arms(self) -> bool {
622622
matches!(self, ValidOnly | MaybeInvalidButAllowOmittingArms)
623623
}
624624

@@ -628,11 +628,7 @@ impl ValidityConstraint {
628628
///
629629
/// Pending further opsem decisions, the current behavior is: validity is preserved, except
630630
/// inside `&` and union fields where validity is reset to `MaybeInvalid`.
631-
pub(super) fn specialize<'tcx>(
632-
self,
633-
pcx: &PatCtxt<'_, '_, 'tcx>,
634-
ctor: &Constructor<'tcx>,
635-
) -> Self {
631+
fn specialize<'tcx>(self, pcx: &PatCtxt<'_, '_, 'tcx>, ctor: &Constructor<'tcx>) -> Self {
636632
// We preserve validity except when we go inside a reference or a union field.
637633
if matches!(ctor, Constructor::Single)
638634
&& (matches!(pcx.ty.kind(), ty::Ref(..))
@@ -1023,7 +1019,7 @@ impl<'p, 'tcx> fmt::Debug for Matrix<'p, 'tcx> {
10231019
///
10241020
/// See the top of the file for more detailed explanations and examples.
10251021
#[derive(Debug, Clone)]
1026-
pub(crate) struct WitnessStack<'tcx>(Vec<WitnessPat<'tcx>>);
1022+
struct WitnessStack<'tcx>(Vec<WitnessPat<'tcx>>);
10271023

10281024
impl<'tcx> WitnessStack<'tcx> {
10291025
/// Asserts that the witness contains a single pattern, and returns it.
@@ -1070,7 +1066,7 @@ impl<'tcx> WitnessStack<'tcx> {
10701066
/// Just as the `Matrix` starts with a single column, by the end of the algorithm, this has a single
10711067
/// column, which contains the patterns that are missing for the match to be exhaustive.
10721068
#[derive(Debug, Clone)]
1073-
pub struct WitnessMatrix<'tcx>(Vec<WitnessStack<'tcx>>);
1069+
struct WitnessMatrix<'tcx>(Vec<WitnessStack<'tcx>>);
10741070

10751071
impl<'tcx> WitnessMatrix<'tcx> {
10761072
/// New matrix with no witnesses.

0 commit comments

Comments
 (0)