Skip to content

Commit 28b6471

Browse files
committed
Separate PlaceCtxt from UsefulnessCtxt
1 parent d6bd64a commit 28b6471

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

compiler/rustc_pattern_analysis/src/usefulness.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -741,28 +741,28 @@ pub struct UsefulnessCtxt<'a, Cx: TypeCx> {
741741
#[derive(derivative::Derivative)]
742742
#[derivative(Debug(bound = ""), Clone(bound = ""), Copy(bound = ""))]
743743
struct PlaceCtxt<'a, Cx: TypeCx> {
744-
#[derivative(Debug = "ignore")]
745-
pub(crate) mcx: UsefulnessCtxt<'a, Cx>,
744+
#[derivative(Debug = "ignore", Clone(clone_with = "Clone::clone"))] // See rust-derivative#90
745+
pub(crate) cx: &'a Cx,
746746
/// Type of the place under investigation.
747747
#[derivative(Clone(clone_with = "Clone::clone"))] // See rust-derivative#90
748748
pub(crate) ty: &'a Cx::Ty,
749749
}
750750

751751
impl<'a, Cx: TypeCx> PlaceCtxt<'a, Cx> {
752752
fn ctor_arity(&self, ctor: &Constructor<Cx>) -> usize {
753-
self.mcx.tycx.ctor_arity(ctor, self.ty)
753+
self.cx.ctor_arity(ctor, self.ty)
754754
}
755755
fn ctor_sub_tys(
756756
&'a self,
757757
ctor: &'a Constructor<Cx>,
758758
) -> impl Iterator<Item = Cx::Ty> + ExactSizeIterator + Captures<'a> {
759-
self.mcx.tycx.ctor_sub_tys(ctor, self.ty)
759+
self.cx.ctor_sub_tys(ctor, self.ty)
760760
}
761761
fn ctors_for_ty(&self) -> Result<ConstructorSet<Cx>, Cx::Error> {
762-
self.mcx.tycx.ctors_for_ty(self.ty)
762+
self.cx.ctors_for_ty(self.ty)
763763
}
764764
fn wild_from_ctor(&self, ctor: Constructor<Cx>) -> WitnessPat<Cx> {
765-
WitnessPat::wild_from_ctor(self.mcx.tycx, ctor, self.ty.clone())
765+
WitnessPat::wild_from_ctor(self.cx, ctor, self.ty.clone())
766766
}
767767
}
768768

@@ -1079,7 +1079,7 @@ impl<'p, Cx: TypeCx> Matrix<'p, Cx> {
10791079
wildcard_row_is_relevant: self.wildcard_row_is_relevant && ctor_is_relevant,
10801080
};
10811081
for (i, row) in self.rows().enumerate() {
1082-
if ctor.is_covered_by(pcx.mcx.tycx, row.head().ctor()) {
1082+
if ctor.is_covered_by(pcx.cx, row.head().ctor()) {
10831083
let new_row = row.pop_head_constructor(ctor, arity, ctor_is_relevant, i);
10841084
matrix.expand_and_push(new_row);
10851085
}
@@ -1439,7 +1439,7 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
14391439
};
14401440

14411441
debug!("ty: {ty:?}");
1442-
let pcx = &PlaceCtxt { mcx, ty: &ty };
1442+
let pcx = &PlaceCtxt { cx: mcx.tycx, ty: &ty };
14431443
let ctors_for_ty = pcx.ctors_for_ty()?;
14441444

14451445
// Whether the place/column we are inspecting is known to contain valid data.

0 commit comments

Comments
 (0)