Skip to content

Commit 7884e17

Browse files
authored
Rollup merge of #137097 - compiler-errors:sized-bound-self, r=oli-obk
Ignore Self in bounds check for associated types with Self:Sized Fixes #137053 This is morally a fix of #112319, since the `Self: Sized` check was just missing here. r? oli-obk
2 parents f10f0f0 + 309e371 commit 7884e17

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs

+3
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,10 @@ fn predicates_reference_self(
187187
fn bounds_reference_self(tcx: TyCtxt<'_>, trait_def_id: DefId) -> SmallVec<[Span; 1]> {
188188
tcx.associated_items(trait_def_id)
189189
.in_definition_order()
190+
// We're only looking at associated type bounds
190191
.filter(|item| item.kind == ty::AssocKind::Type)
192+
// Ignore GATs with `Self: Sized`
193+
.filter(|item| !tcx.generics_require_sized_self(item.def_id))
191194
.flat_map(|item| tcx.explicit_item_bounds(item.def_id).iter_identity_copied())
192195
.filter_map(|(clause, sp)| {
193196
// Item bounds *can* have self projections, since they never get
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Ensure that we properly ignore the `B<Self>` associated type bound on `A::T`
2+
// since that associated type requires `Self: Sized`.
3+
4+
//@ check-pass
5+
6+
struct X(&'static dyn A);
7+
8+
trait A {
9+
type T: B<Self> where Self: Sized;
10+
}
11+
12+
trait B<T> {}
13+
14+
fn main() {}

0 commit comments

Comments
 (0)