1
Fork 0

s/MatchCx/TypeCx/

This commit is contained in:
Nadrieril 2023-12-15 17:25:11 +01:00
parent 4bcf66f875
commit 3016c29628
6 changed files with 48 additions and 48 deletions

View file

@ -40,7 +40,7 @@
//! - That have no non-trivial intersection with any of the constructors in the column (i.e. they're
//! each either disjoint with or covered by any given column constructor).
//!
//! We compute this in two steps: first [`MatchCx::ctors_for_ty`] determines the
//! We compute this in two steps: first [`TypeCx::ctors_for_ty`] determines the
//! set of all possible constructors for the type. Then [`ConstructorSet::split`] looks at the
//! column of constructors and splits the set into groups accordingly. The precise invariants of
//! [`ConstructorSet::split`] is described in [`SplitConstructorSet`].
@ -136,7 +136,7 @@
//! the algorithm can't distinguish them from a nonempty constructor. The only known case where this
//! could happen is the `[..]` pattern on `[!; N]` with `N > 0` so we must take care to not emit it.
//!
//! This is all handled by [`MatchCx::ctors_for_ty`] and
//! This is all handled by [`TypeCx::ctors_for_ty`] and
//! [`ConstructorSet::split`]. The invariants of [`SplitConstructorSet`] are also of interest.
//!
//!
@ -163,7 +163,7 @@ use self::MaybeInfiniteInt::*;
use self::SliceKind::*;
use crate::usefulness::PlaceCtxt;
use crate::MatchCx;
use crate::TypeCx;
/// Whether we have seen a constructor in the column or not.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
@ -643,7 +643,7 @@ impl OpaqueId {
/// constructor. `Constructor::apply` reconstructs the pattern from a pair of `Constructor` and
/// `Fields`.
#[derive(Clone, Debug, PartialEq)]
pub enum Constructor<Cx: MatchCx> {
pub enum Constructor<Cx: TypeCx> {
/// Tuples and structs.
Struct,
/// Enum variants.
@ -685,7 +685,7 @@ pub enum Constructor<Cx: MatchCx> {
Missing,
}
impl<Cx: MatchCx> Constructor<Cx> {
impl<Cx: TypeCx> Constructor<Cx> {
pub(crate) fn is_non_exhaustive(&self) -> bool {
matches!(self, NonExhaustive)
}
@ -798,7 +798,7 @@ pub enum VariantVisibility {
/// In terms of division of responsibility, [`ConstructorSet::split`] handles all of the
/// `exhaustive_patterns` feature.
#[derive(Debug)]
pub enum ConstructorSet<Cx: MatchCx> {
pub enum ConstructorSet<Cx: TypeCx> {
/// The type is a tuple or struct. `empty` tracks whether the type is empty.
Struct { empty: bool },
/// This type has the following list of constructors. If `variants` is empty and
@ -846,13 +846,13 @@ pub enum ConstructorSet<Cx: MatchCx> {
/// 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(crate) struct SplitConstructorSet<Cx: MatchCx> {
pub(crate) struct SplitConstructorSet<Cx: TypeCx> {
pub(crate) present: SmallVec<[Constructor<Cx>; 1]>,
pub(crate) missing: Vec<Constructor<Cx>>,
pub(crate) missing_empty: Vec<Constructor<Cx>>,
}
impl<Cx: MatchCx> ConstructorSet<Cx> {
impl<Cx: TypeCx> ConstructorSet<Cx> {
/// This analyzes a column of constructors to 1/ determine which constructors of the type (if
/// any) are missing; 2/ split constructors to handle non-trivial intersections e.g. on ranges
/// or slices. This can get subtle; see [`SplitConstructorSet`] for details of this operation