Skip to content

Commit

Permalink
Don't check RPITITs that are Self:Sized for PointerLike
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Dec 10, 2024
1 parent a7fa4cb commit 57e8a1c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions tests/ui/impl-trait/in-trait/sized-rpits-dont-need-pointer-like.rs
Original file line number Diff line number Diff line change
@@ -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 = &();
}

0 comments on commit 57e8a1c

Please sign in to comment.