1
Fork 0

Don't check RPITITs that are Self:Sized for PointerLike

This commit is contained in:
Michael Goulet 2024-12-10 17:20:54 +00:00
parent a7fa4cbcb4
commit 57e8a1c9c3
2 changed files with 18 additions and 0 deletions

View file

@ -1197,6 +1197,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
continue;
}
// RPITITs with `Self: Sized` don't need to be checked.
if tcx.generics_require_sized_self(assoc_item) {
continue;
}
let pointer_like_goal = pointer_like_goal_for_rpitit(
tcx,
supertrait,

View file

@ -0,0 +1,13 @@
//@ check-pass
// Make sure that we don't enforce that an RPIT that has `where Self: Sized` is pointer-like.
trait Foo {
fn foo() -> impl Sized where Self: Sized {}
}
impl Foo for () {}
fn main() {
let x: &dyn Foo = &();
}