Skip to content

Commit acd463f

Browse files
committed
Separate PlaceCtxt from UsefulnessCtxt
1 parent 60dfd20 commit acd463f

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,25 +741,25 @@ 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(&self, ctor: &Constructor<Cx>) -> &[Cx::Ty] {
756-
self.mcx.tycx.ctor_sub_tys(ctor, self.ty)
756+
self.cx.ctor_sub_tys(ctor, self.ty)
757757
}
758758
fn ctors_for_ty(&self) -> Result<ConstructorSet<Cx>, Cx::Error> {
759-
self.mcx.tycx.ctors_for_ty(self.ty)
759+
self.cx.ctors_for_ty(self.ty)
760760
}
761761
fn wild_from_ctor(&self, ctor: Constructor<Cx>) -> WitnessPat<Cx> {
762-
WitnessPat::wild_from_ctor(self.mcx.tycx, ctor, self.ty.clone())
762+
WitnessPat::wild_from_ctor(self.cx, ctor, self.ty.clone())
763763
}
764764
}
765765

@@ -1077,7 +1077,7 @@ impl<'p, Cx: TypeCx> Matrix<'p, Cx> {
10771077
wildcard_row_is_relevant: self.wildcard_row_is_relevant && ctor_is_relevant,
10781078
};
10791079
for (i, row) in self.rows().enumerate() {
1080-
if ctor.is_covered_by(pcx.mcx.tycx, row.head().ctor()) {
1080+
if ctor.is_covered_by(pcx.cx, row.head().ctor()) {
10811081
let new_row = row.pop_head_constructor(ctor, arity, ctor_is_relevant, i);
10821082
matrix.expand_and_push(new_row);
10831083
}
@@ -1437,7 +1437,7 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
14371437
};
14381438

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

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

0 commit comments

Comments
 (0)