Strip OpaqueCast during RevealAll.

This commit is contained in:
Oli Scherer 2023-09-27 11:20:17 +00:00
parent 479fa4a74d
commit 6ea2db7c2d
10 changed files with 57 additions and 26 deletions

View file

@ -25,6 +25,25 @@ impl<'tcx> MutVisitor<'tcx> for RevealAllVisitor<'tcx> {
self.tcx
}
#[inline]
fn visit_place(
&mut self,
place: &mut Place<'tcx>,
_context: PlaceContext,
_location: Location,
) {
// `OpaqueCast` projections are only needed if there are opaque types on which projections are performed.
// After the `RevealAll` pass, all opaque types are replaced with their hidden types, so we don't need these
// projections anymore.
place.projection = self.tcx.mk_place_elems(
&place
.projection
.into_iter()
.filter(|elem| !matches!(elem, ProjectionElem::OpaqueCast(_)))
.collect::<Vec<_>>(),
);
}
#[inline]
fn visit_constant(&mut self, constant: &mut ConstOperand<'tcx>, _: Location) {
// We have to use `try_normalize_erasing_regions` here, since it's