Skip to content

Commit

Permalink
also remap RPITITs nested in other types back to their opaques
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Markeffsky committed Apr 21, 2024
1 parent 31a05a2 commit 5a2b335
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/collect/item_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rustc_data_structures::fx::FxIndexSet;
use rustc_hir as hir;
use rustc_infer::traits::util;
use rustc_middle::ty::GenericArgs;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeFolder};
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable};
use rustc_span::def_id::{DefId, LocalDefId};
use rustc_span::Span;

Expand Down Expand Up @@ -214,7 +214,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTyToOpaque<'tcx> {
{
self.tcx.type_of(projection_ty.def_id).instantiate(self.tcx, projection_ty.args)
} else {
ty
ty.super_fold_with(self)
}
}
}
4 changes: 4 additions & 0 deletions tests/ui/impl-trait/in-trait/nested-rpitit-bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ trait Foo {
fn foo() -> impl Deref<Target = impl Deref<Target = impl Sized>> {
&&()
}

fn bar() -> impl Deref<Target = Option<impl Sized>> {
&Some(())
}
}

fn main() {}

0 comments on commit 5a2b335

Please sign in to comment.