mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Fix item visibilities
This commit is contained in:
parent
de3f983bcd
commit
5d6c539c2d
@ -253,7 +253,7 @@ pub struct IntRange {
|
||||
|
||||
impl IntRange {
|
||||
/// Best effort; will not know that e.g. `255u8..` is a singleton.
|
||||
pub fn is_singleton(&self) -> bool {
|
||||
pub(crate) fn is_singleton(&self) -> bool {
|
||||
// Since `lo` and `hi` can't be the same `Infinity` and `plus_one` never changes from finite
|
||||
// to infinite, this correctly only detects ranges that contain exacly one `Finite(x)`.
|
||||
self.lo.plus_one() == self.hi
|
||||
@ -670,11 +670,11 @@ pub enum Constructor<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Constructor<'tcx> {
|
||||
pub(super) fn is_non_exhaustive(&self) -> bool {
|
||||
pub(crate) fn is_non_exhaustive(&self) -> bool {
|
||||
matches!(self, NonExhaustive)
|
||||
}
|
||||
|
||||
pub(super) fn as_variant(&self) -> Option<VariantIdx> {
|
||||
pub(crate) fn as_variant(&self) -> Option<VariantIdx> {
|
||||
match self {
|
||||
Variant(i) => Some(*i),
|
||||
_ => None,
|
||||
@ -686,7 +686,7 @@ impl<'tcx> Constructor<'tcx> {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
pub(super) fn as_int_range(&self) -> Option<&IntRange> {
|
||||
pub(crate) fn as_int_range(&self) -> Option<&IntRange> {
|
||||
match self {
|
||||
IntRange(range) => Some(range),
|
||||
_ => None,
|
||||
@ -830,10 +830,10 @@ pub enum ConstructorSet {
|
||||
/// of the `ConstructorSet` for the type, yet if we forgot to include them in `present` we would be
|
||||
/// ignoring any row with `Opaque`s in the algorithm. Hence the importance of point 4.
|
||||
#[derive(Debug)]
|
||||
pub(super) struct SplitConstructorSet<'tcx> {
|
||||
pub(super) present: SmallVec<[Constructor<'tcx>; 1]>,
|
||||
pub(super) missing: Vec<Constructor<'tcx>>,
|
||||
pub(super) missing_empty: Vec<Constructor<'tcx>>,
|
||||
pub(crate) struct SplitConstructorSet<'tcx> {
|
||||
pub(crate) present: SmallVec<[Constructor<'tcx>; 1]>,
|
||||
pub(crate) missing: Vec<Constructor<'tcx>>,
|
||||
pub(crate) missing_empty: Vec<Constructor<'tcx>>,
|
||||
}
|
||||
|
||||
impl ConstructorSet {
|
||||
@ -842,7 +842,7 @@ impl ConstructorSet {
|
||||
/// or slices. This can get subtle; see [`SplitConstructorSet`] for details of this operation
|
||||
/// and its invariants.
|
||||
#[instrument(level = "debug", skip(self, pcx, ctors), ret)]
|
||||
pub(super) fn split<'a, 'tcx>(
|
||||
pub(crate) fn split<'a, 'tcx>(
|
||||
&self,
|
||||
pcx: &PatCtxt<'_, '_, 'tcx>,
|
||||
ctors: impl Iterator<Item = &'a Constructor<'tcx>> + Clone,
|
||||
|
@ -37,11 +37,11 @@ pub struct DeconstructedPat<'p, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
|
||||
pub(super) fn wildcard(ty: Ty<'tcx>, span: Span) -> Self {
|
||||
pub fn wildcard(ty: Ty<'tcx>, span: Span) -> Self {
|
||||
Self::new(Wildcard, &[], ty, span)
|
||||
}
|
||||
|
||||
pub(super) fn new(
|
||||
pub fn new(
|
||||
ctor: Constructor<'tcx>,
|
||||
fields: &'p [DeconstructedPat<'p, 'tcx>],
|
||||
ty: Ty<'tcx>,
|
||||
@ -50,11 +50,11 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
|
||||
DeconstructedPat { ctor, fields, ty, span, useful: Cell::new(false) }
|
||||
}
|
||||
|
||||
pub(super) fn is_or_pat(&self) -> bool {
|
||||
pub(crate) fn is_or_pat(&self) -> bool {
|
||||
matches!(self.ctor, Or)
|
||||
}
|
||||
/// Expand this (possibly-nested) or-pattern into its alternatives.
|
||||
pub(super) fn flatten_or_pat(&'p self) -> SmallVec<[&'p Self; 1]> {
|
||||
pub(crate) fn flatten_or_pat(&'p self) -> SmallVec<[&'p Self; 1]> {
|
||||
if self.is_or_pat() {
|
||||
self.iter_fields().flat_map(|p| p.flatten_or_pat()).collect()
|
||||
} else {
|
||||
@ -80,7 +80,7 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
|
||||
|
||||
/// Specialize this pattern with a constructor.
|
||||
/// `other_ctor` can be different from `self.ctor`, but must be covered by it.
|
||||
pub(super) fn specialize<'a>(
|
||||
pub(crate) fn specialize<'a>(
|
||||
&'a self,
|
||||
pcx: &PatCtxt<'_, 'p, 'tcx>,
|
||||
other_ctor: &Constructor<'tcx>,
|
||||
@ -122,10 +122,10 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
|
||||
|
||||
/// We keep track for each pattern if it was ever useful during the analysis. This is used
|
||||
/// with `redundant_spans` to report redundant subpatterns arising from or patterns.
|
||||
pub(super) fn set_useful(&self) {
|
||||
pub(crate) fn set_useful(&self) {
|
||||
self.useful.set(true)
|
||||
}
|
||||
pub(super) fn is_useful(&self) -> bool {
|
||||
pub(crate) fn is_useful(&self) -> bool {
|
||||
if self.useful.get() {
|
||||
true
|
||||
} else if self.is_or_pat() && self.iter_fields().any(|f| f.is_useful()) {
|
||||
@ -140,7 +140,7 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
|
||||
}
|
||||
|
||||
/// Report the spans of subpatterns that were not useful, if any.
|
||||
pub(super) fn redundant_spans(&self) -> Vec<Span> {
|
||||
pub(crate) fn redundant_spans(&self) -> Vec<Span> {
|
||||
let mut spans = Vec::new();
|
||||
self.collect_redundant_spans(&mut spans);
|
||||
spans
|
||||
@ -175,17 +175,17 @@ pub struct WitnessPat<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> WitnessPat<'tcx> {
|
||||
pub(super) fn new(ctor: Constructor<'tcx>, fields: Vec<Self>, ty: Ty<'tcx>) -> Self {
|
||||
pub(crate) fn new(ctor: Constructor<'tcx>, fields: Vec<Self>, ty: Ty<'tcx>) -> Self {
|
||||
Self { ctor, fields, ty }
|
||||
}
|
||||
pub(super) fn wildcard(ty: Ty<'tcx>) -> Self {
|
||||
pub(crate) fn wildcard(ty: Ty<'tcx>) -> Self {
|
||||
Self::new(Wildcard, Vec::new(), ty)
|
||||
}
|
||||
|
||||
/// Construct a pattern that matches everything that starts with this constructor.
|
||||
/// For example, if `ctor` is a `Constructor::Variant` for `Option::Some`, we get the pattern
|
||||
/// `Some(_)`.
|
||||
pub(super) fn wild_from_ctor(pcx: &PatCtxt<'_, '_, 'tcx>, ctor: Constructor<'tcx>) -> Self {
|
||||
pub(crate) fn wild_from_ctor(pcx: &PatCtxt<'_, '_, 'tcx>, ctor: Constructor<'tcx>) -> Self {
|
||||
let field_tys =
|
||||
pcx.cx.ctor_wildcard_fields(&ctor, pcx.ty).iter().map(|deco_pat| deco_pat.ty());
|
||||
let fields = field_tys.map(|ty| Self::wildcard(ty)).collect();
|
||||
|
@ -594,7 +594,7 @@ impl<'a, 'p, 'tcx> fmt::Debug for PatCtxt<'a, 'p, 'tcx> {
|
||||
/// - in the matrix, track whether a given place (aka column) is known to contain a valid value or
|
||||
/// not.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub(super) enum ValidityConstraint {
|
||||
enum ValidityConstraint {
|
||||
ValidOnly,
|
||||
MaybeInvalid,
|
||||
/// Option for backwards compatibility: the place is not known to be valid but we allow omitting
|
||||
@ -603,7 +603,7 @@ pub(super) enum ValidityConstraint {
|
||||
}
|
||||
|
||||
impl ValidityConstraint {
|
||||
pub(super) fn from_bool(is_valid_only: bool) -> Self {
|
||||
fn from_bool(is_valid_only: bool) -> Self {
|
||||
if is_valid_only { ValidOnly } else { MaybeInvalid }
|
||||
}
|
||||
|
||||
@ -615,10 +615,10 @@ impl ValidityConstraint {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn is_known_valid(self) -> bool {
|
||||
fn is_known_valid(self) -> bool {
|
||||
matches!(self, ValidOnly)
|
||||
}
|
||||
pub(super) fn allows_omitting_empty_arms(self) -> bool {
|
||||
fn allows_omitting_empty_arms(self) -> bool {
|
||||
matches!(self, ValidOnly | MaybeInvalidButAllowOmittingArms)
|
||||
}
|
||||
|
||||
@ -628,11 +628,7 @@ impl ValidityConstraint {
|
||||
///
|
||||
/// Pending further opsem decisions, the current behavior is: validity is preserved, except
|
||||
/// inside `&` and union fields where validity is reset to `MaybeInvalid`.
|
||||
pub(super) fn specialize<'tcx>(
|
||||
self,
|
||||
pcx: &PatCtxt<'_, '_, 'tcx>,
|
||||
ctor: &Constructor<'tcx>,
|
||||
) -> Self {
|
||||
fn specialize<'tcx>(self, pcx: &PatCtxt<'_, '_, 'tcx>, ctor: &Constructor<'tcx>) -> Self {
|
||||
// We preserve validity except when we go inside a reference or a union field.
|
||||
if matches!(ctor, Constructor::Single)
|
||||
&& (matches!(pcx.ty.kind(), ty::Ref(..))
|
||||
@ -1023,7 +1019,7 @@ impl<'p, 'tcx> fmt::Debug for Matrix<'p, 'tcx> {
|
||||
///
|
||||
/// See the top of the file for more detailed explanations and examples.
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct WitnessStack<'tcx>(Vec<WitnessPat<'tcx>>);
|
||||
struct WitnessStack<'tcx>(Vec<WitnessPat<'tcx>>);
|
||||
|
||||
impl<'tcx> WitnessStack<'tcx> {
|
||||
/// Asserts that the witness contains a single pattern, and returns it.
|
||||
@ -1070,7 +1066,7 @@ impl<'tcx> WitnessStack<'tcx> {
|
||||
/// Just as the `Matrix` starts with a single column, by the end of the algorithm, this has a single
|
||||
/// column, which contains the patterns that are missing for the match to be exhaustive.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct WitnessMatrix<'tcx>(Vec<WitnessStack<'tcx>>);
|
||||
struct WitnessMatrix<'tcx>(Vec<WitnessStack<'tcx>>);
|
||||
|
||||
impl<'tcx> WitnessMatrix<'tcx> {
|
||||
/// New matrix with no witnesses.
|
||||
|
Loading…
Reference in New Issue
Block a user