Skip to content

Commit 5903142

Browse files
committed
Separate PlaceCtxt from UsefulnessCtxt
1 parent 6ef8362 commit 5903142

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
@@ -745,15 +745,15 @@ impl<'a, Cx: TypeCx> Clone for UsefulnessCtxt<'a, Cx> {
745745

746746
/// Context that provides information local to a place under investigation.
747747
struct PlaceCtxt<'a, Cx: TypeCx> {
748-
mcx: UsefulnessCtxt<'a, Cx>,
748+
cx: &'a Cx,
749749
/// Type of the place under investigation.
750750
ty: &'a Cx::Ty,
751751
}
752752

753753
impl<'a, Cx: TypeCx> Copy for PlaceCtxt<'a, Cx> {}
754754
impl<'a, Cx: TypeCx> Clone for PlaceCtxt<'a, Cx> {
755755
fn clone(&self) -> Self {
756-
Self { mcx: self.mcx, ty: self.ty }
756+
Self { cx: self.cx, ty: self.ty }
757757
}
758758
}
759759

@@ -765,19 +765,19 @@ impl<'a, Cx: TypeCx> fmt::Debug for PlaceCtxt<'a, Cx> {
765765

766766
impl<'a, Cx: TypeCx> PlaceCtxt<'a, Cx> {
767767
fn ctor_arity(&self, ctor: &Constructor<Cx>) -> usize {
768-
self.mcx.tycx.ctor_arity(ctor, self.ty)
768+
self.cx.ctor_arity(ctor, self.ty)
769769
}
770770
fn ctor_sub_tys(
771771
&'a self,
772772
ctor: &'a Constructor<Cx>,
773773
) -> impl Iterator<Item = Cx::Ty> + ExactSizeIterator + Captures<'a> {
774-
self.mcx.tycx.ctor_sub_tys(ctor, self.ty)
774+
self.cx.ctor_sub_tys(ctor, self.ty)
775775
}
776776
fn ctors_for_ty(&self) -> Result<ConstructorSet<Cx>, Cx::Error> {
777-
self.mcx.tycx.ctors_for_ty(self.ty)
777+
self.cx.ctors_for_ty(self.ty)
778778
}
779779
fn wild_from_ctor(&self, ctor: Constructor<Cx>) -> WitnessPat<Cx> {
780-
WitnessPat::wild_from_ctor(self.mcx.tycx, ctor, self.ty.clone())
780+
WitnessPat::wild_from_ctor(self.cx, ctor, self.ty.clone())
781781
}
782782
}
783783

@@ -1098,7 +1098,7 @@ impl<'p, Cx: TypeCx> Matrix<'p, Cx> {
10981098
wildcard_row_is_relevant: self.wildcard_row_is_relevant && ctor_is_relevant,
10991099
};
11001100
for (i, row) in self.rows().enumerate() {
1101-
if ctor.is_covered_by(pcx.mcx.tycx, row.head().ctor()) {
1101+
if ctor.is_covered_by(pcx.cx, row.head().ctor()) {
11021102
let new_row = row.pop_head_constructor(ctor, arity, ctor_is_relevant, i);
11031103
matrix.expand_and_push(new_row);
11041104
}
@@ -1478,7 +1478,7 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
14781478
};
14791479

14801480
debug!("ty: {ty:?}");
1481-
let pcx = &PlaceCtxt { mcx, ty: &ty };
1481+
let pcx = &PlaceCtxt { cx: mcx.tycx, ty: &ty };
14821482
let ctors_for_ty = pcx.ctors_for_ty()?;
14831483

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

0 commit comments

Comments
 (0)