diff options
Diffstat (limited to 'compiler/rustc_pattern_analysis/src/lib.rs')
| -rw-r--r-- | compiler/rustc_pattern_analysis/src/lib.rs | 10 |
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`. /// |
