summary refs log tree commit diff
path: root/compiler/rustc_pattern_analysis/src/lib.rs
diff options
context:
space:
mode:
authorNadrieril <nadrieril+git@gmail.com>2024-02-06 02:44:48 +0100
committerNadrieril <nadrieril+git@gmail.com>2024-02-28 17:47:19 +0100
commitab06037269da9c5fc83083fb7d9d9638294e3d63 (patch)
tree3ad6f38428020dc6c8fcdaf58d0d4b009652a7f1 /compiler/rustc_pattern_analysis/src/lib.rs
parentbe01e28dceb5e8e32bb1c97f3be5c5488eed8f4f (diff)
downloadrust-ab06037269da9c5fc83083fb7d9d9638294e3d63.tar.gz
rust-ab06037269da9c5fc83083fb7d9d9638294e3d63.zip
Push the decision to skip fields further down
Diffstat (limited to 'compiler/rustc_pattern_analysis/src/lib.rs')
-rw-r--r--compiler/rustc_pattern_analysis/src/lib.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_pattern_analysis/src/lib.rs b/compiler/rustc_pattern_analysis/src/lib.rs
index 164dc36b679..0b4bc77a976 100644
--- a/compiler/rustc_pattern_analysis/src/lib.rs
+++ b/compiler/rustc_pattern_analysis/src/lib.rs
@@ -82,6 +82,10 @@ use crate::usefulness::{compute_match_usefulness, ValidityConstraint};
 pub trait Captures<'a> {}
 impl<'a, T: ?Sized> Captures<'a> for T {}
 
+/// `bool` newtype that indicates whether we should skip this field during analysis.
+#[derive(Copy, Clone, Debug, PartialEq, Eq)]
+pub struct SkipField(pub bool);
+
 /// Context that provides type information about constructors.
 ///
 /// Most of the crate is parameterized on a type that implements this trait.
@@ -105,13 +109,13 @@ pub trait TypeCx: Sized + fmt::Debug {
     /// The number of fields for this constructor.
     fn ctor_arity(&self, ctor: &Constructor<Self>, ty: &Self::Ty) -> usize;
 
-    /// The types of the fields for this constructor. The result must have a length of
-    /// `ctor_arity()`.
+    /// The types of the fields for this constructor. The result must contain `ctor_arity()`-many
+    /// fields that are not skipped.
     fn ctor_sub_tys<'a>(
         &'a self,
         ctor: &'a Constructor<Self>,
         ty: &'a Self::Ty,
-    ) -> impl Iterator<Item = Self::Ty> + ExactSizeIterator + Captures<'a>;
+    ) -> impl Iterator<Item = (Self::Ty, SkipField)> + ExactSizeIterator + Captures<'a>;
 
     /// The set of all the constructors for `ty`.
     ///