Even more
This commit is contained in:
parent
eebb2abe0b
commit
b91a98ba10
2 changed files with 10 additions and 13 deletions
|
@ -131,7 +131,7 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> {
|
||||||
pub(crate) fn list_variant_nonhidden_fields<'a>(
|
pub(crate) fn list_variant_nonhidden_fields<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
variant: &'a VariantDef,
|
variant: &'a VariantDef, // TODO:
|
||||||
) -> impl Iterator<Item = (FieldIdx, Ty<'tcx>)> + Captures<'p> + Captures<'a> {
|
) -> impl Iterator<Item = (FieldIdx, Ty<'tcx>)> + Captures<'p> + Captures<'a> {
|
||||||
let cx = self;
|
let cx = self;
|
||||||
let ty::Adt(adt, args) = ty.kind() else { bug!() };
|
let ty::Adt(adt, args) = ty.kind() else { bug!() };
|
||||||
|
|
|
@ -821,7 +821,6 @@ impl fmt::Display for ValidityConstraint {
|
||||||
|
|
||||||
/// Represents a pattern-tuple under investigation.
|
/// Represents a pattern-tuple under investigation.
|
||||||
// The three lifetimes are:
|
// The three lifetimes are:
|
||||||
// - 'a allocated by us
|
|
||||||
// - 'p coming from the input
|
// - 'p coming from the input
|
||||||
// - Cx global compilation context
|
// - Cx global compilation context
|
||||||
#[derive(derivative::Derivative)]
|
#[derive(derivative::Derivative)]
|
||||||
|
@ -835,7 +834,7 @@ struct PatStack<'p, Cx: TypeCx> {
|
||||||
relevant: bool,
|
relevant: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'p, Cx: TypeCx> PatStack<'p, Cx> {
|
impl<'p, Cx: TypeCx> PatStack<'p, Cx> {
|
||||||
fn from_pattern(pat: &'p DeconstructedPat<'p, Cx>) -> Self {
|
fn from_pattern(pat: &'p DeconstructedPat<'p, Cx>) -> Self {
|
||||||
PatStack { pats: smallvec![pat], relevant: true }
|
PatStack { pats: smallvec![pat], relevant: true }
|
||||||
}
|
}
|
||||||
|
@ -870,7 +869,7 @@ impl<'a, 'p, Cx: TypeCx> PatStack<'p, Cx> {
|
||||||
/// Only call if `ctor.is_covered_by(self.head().ctor())` is true.
|
/// Only call if `ctor.is_covered_by(self.head().ctor())` is true.
|
||||||
fn pop_head_constructor(
|
fn pop_head_constructor(
|
||||||
&self,
|
&self,
|
||||||
pcx: &PlaceCtxt<'a, 'p, Cx>,
|
pcx: &PlaceCtxt<'_, 'p, Cx>,
|
||||||
ctor: &Constructor<Cx>,
|
ctor: &Constructor<Cx>,
|
||||||
ctor_is_relevant: bool,
|
ctor_is_relevant: bool,
|
||||||
) -> PatStack<'p, Cx> {
|
) -> PatStack<'p, Cx> {
|
||||||
|
@ -914,7 +913,7 @@ struct MatrixRow<'p, Cx: TypeCx> {
|
||||||
useful: bool,
|
useful: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'p, Cx: TypeCx> MatrixRow<'p, Cx> {
|
impl<'p, Cx: TypeCx> MatrixRow<'p, Cx> {
|
||||||
fn is_empty(&self) -> bool {
|
fn is_empty(&self) -> bool {
|
||||||
self.pats.is_empty()
|
self.pats.is_empty()
|
||||||
}
|
}
|
||||||
|
@ -946,7 +945,7 @@ impl<'a, 'p, Cx: TypeCx> MatrixRow<'p, Cx> {
|
||||||
/// Only call if `ctor.is_covered_by(self.head().ctor())` is true.
|
/// Only call if `ctor.is_covered_by(self.head().ctor())` is true.
|
||||||
fn pop_head_constructor(
|
fn pop_head_constructor(
|
||||||
&self,
|
&self,
|
||||||
pcx: &PlaceCtxt<'a, 'p, Cx>,
|
pcx: &PlaceCtxt<'_, 'p, Cx>,
|
||||||
ctor: &Constructor<Cx>,
|
ctor: &Constructor<Cx>,
|
||||||
ctor_is_relevant: bool,
|
ctor_is_relevant: bool,
|
||||||
parent_row: usize,
|
parent_row: usize,
|
||||||
|
@ -989,7 +988,7 @@ struct Matrix<'p, Cx: TypeCx> {
|
||||||
place_validity: SmallVec<[ValidityConstraint; 2]>,
|
place_validity: SmallVec<[ValidityConstraint; 2]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'p, Cx: TypeCx> Matrix<'p, Cx> {
|
impl<'p, Cx: TypeCx> Matrix<'p, Cx> {
|
||||||
/// Pushes a new row to the matrix. If the row starts with an or-pattern, this recursively
|
/// Pushes a new row to the matrix. If the row starts with an or-pattern, this recursively
|
||||||
/// expands it. Internal method, prefer [`Matrix::new`].
|
/// expands it. Internal method, prefer [`Matrix::new`].
|
||||||
fn expand_and_push(&mut self, row: MatrixRow<'p, Cx>) {
|
fn expand_and_push(&mut self, row: MatrixRow<'p, Cx>) {
|
||||||
|
@ -1006,7 +1005,7 @@ impl<'a, 'p, Cx: TypeCx> Matrix<'p, Cx> {
|
||||||
/// Build a new matrix from an iterator of `MatchArm`s.
|
/// Build a new matrix from an iterator of `MatchArm`s.
|
||||||
fn new(
|
fn new(
|
||||||
wildcard_arena: &'p TypedArena<DeconstructedPat<'p, Cx>>,
|
wildcard_arena: &'p TypedArena<DeconstructedPat<'p, Cx>>,
|
||||||
arms: &'a [MatchArm<'p, Cx>],
|
arms: &[MatchArm<'p, Cx>],
|
||||||
scrut_ty: Cx::Ty,
|
scrut_ty: Cx::Ty,
|
||||||
scrut_validity: ValidityConstraint,
|
scrut_validity: ValidityConstraint,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -1029,7 +1028,7 @@ impl<'a, 'p, Cx: TypeCx> Matrix<'p, Cx> {
|
||||||
matrix
|
matrix
|
||||||
}
|
}
|
||||||
|
|
||||||
fn head_ty(&self, mcx: MatchCtxt<'a, 'p, Cx>) -> Option<Cx::Ty> {
|
fn head_ty(&self, mcx: MatchCtxt<'_, 'p, Cx>) -> Option<Cx::Ty> {
|
||||||
if self.column_count() == 0 {
|
if self.column_count() == 0 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -1056,16 +1055,14 @@ impl<'a, 'p, Cx: TypeCx> Matrix<'p, Cx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterate over the first pattern of each row.
|
/// Iterate over the first pattern of each row.
|
||||||
fn heads<'b>(
|
fn heads<'b>(&'b self) -> impl Iterator<Item = &'b DeconstructedPat<'p, Cx>> + Clone {
|
||||||
&'b self,
|
|
||||||
) -> impl Iterator<Item = &'b DeconstructedPat<'p, Cx>> + Clone + Captures<'a> {
|
|
||||||
self.rows().map(|r| r.head())
|
self.rows().map(|r| r.head())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This computes `specialize(ctor, self)`. See top of the file for explanations.
|
/// This computes `specialize(ctor, self)`. See top of the file for explanations.
|
||||||
fn specialize_constructor(
|
fn specialize_constructor(
|
||||||
&self,
|
&self,
|
||||||
pcx: &PlaceCtxt<'a, 'p, Cx>,
|
pcx: &PlaceCtxt<'_, 'p, Cx>,
|
||||||
ctor: &Constructor<Cx>,
|
ctor: &Constructor<Cx>,
|
||||||
ctor_is_relevant: bool,
|
ctor_is_relevant: bool,
|
||||||
) -> Matrix<'p, Cx> {
|
) -> Matrix<'p, Cx> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue