Rollup merge of #139902 - lcnr:no-opaque-cast-projection, r=oli-obk
do not emit `OpaqueCast` projections with `-Znext-solver` We normalize opaque types in their defining scope if the new solver is enabled. This means projections do not contain any 'revealable' opaque types we need to worry about. We either have a type which has been normalized by writeback or we need to normalize it anyways. r? ```@compiler-errors``` ```@oli-obk```
This commit is contained in:
commit
67e2358fbb
8 changed files with 52 additions and 35 deletions
|
@ -39,20 +39,22 @@ impl<'tcx> MutVisitor<'tcx> for PostAnalysisNormalizeVisitor<'tcx> {
|
|||
_context: PlaceContext,
|
||||
_location: Location,
|
||||
) {
|
||||
// Performance optimization: don't reintern if there is no `OpaqueCast` to remove.
|
||||
if place.projection.iter().all(|elem| !matches!(elem, ProjectionElem::OpaqueCast(_))) {
|
||||
return;
|
||||
if !self.tcx.next_trait_solver_globally() {
|
||||
// `OpaqueCast` projections are only needed if there are opaque types on which projections
|
||||
// are performed. After the `PostAnalysisNormalize` pass, all opaque types are replaced with their
|
||||
// hidden types, so we don't need these projections anymore.
|
||||
//
|
||||
// Performance optimization: don't reintern if there is no `OpaqueCast` to remove.
|
||||
if place.projection.iter().any(|elem| matches!(elem, ProjectionElem::OpaqueCast(_))) {
|
||||
place.projection = self.tcx.mk_place_elems(
|
||||
&place
|
||||
.projection
|
||||
.into_iter()
|
||||
.filter(|elem| !matches!(elem, ProjectionElem::OpaqueCast(_)))
|
||||
.collect::<Vec<_>>(),
|
||||
);
|
||||
};
|
||||
}
|
||||
// `OpaqueCast` projections are only needed if there are opaque types on which projections
|
||||
// are performed. After the `PostAnalysisNormalize` 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<_>>(),
|
||||
);
|
||||
self.super_place(place, _context, _location);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue