Skip to content

Commit 57e8a1c

Browse files
Don't check RPITITs that are Self:Sized for PointerLike
1 parent a7fa4cb commit 57e8a1c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11971197
continue;
11981198
}
11991199

1200+
// RPITITs with `Self: Sized` don't need to be checked.
1201+
if tcx.generics_require_sized_self(assoc_item) {
1202+
continue;
1203+
}
1204+
12001205
let pointer_like_goal = pointer_like_goal_for_rpitit(
12011206
tcx,
12021207
supertrait,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ check-pass
2+
3+
// Make sure that we don't enforce that an RPIT that has `where Self: Sized` is pointer-like.
4+
5+
trait Foo {
6+
fn foo() -> impl Sized where Self: Sized {}
7+
}
8+
9+
impl Foo for () {}
10+
11+
fn main() {
12+
let x: &dyn Foo = &();
13+
}

0 commit comments

Comments
 (0)