Ignore Self in bounds check for associated types with Self:Sized
This commit is contained in:
parent
608e228ca9
commit
309e371f7b
2 changed files with 17 additions and 0 deletions
|
@ -187,7 +187,10 @@ fn predicates_reference_self(
|
||||||
fn bounds_reference_self(tcx: TyCtxt<'_>, trait_def_id: DefId) -> SmallVec<[Span; 1]> {
|
fn bounds_reference_self(tcx: TyCtxt<'_>, trait_def_id: DefId) -> SmallVec<[Span; 1]> {
|
||||||
tcx.associated_items(trait_def_id)
|
tcx.associated_items(trait_def_id)
|
||||||
.in_definition_order()
|
.in_definition_order()
|
||||||
|
// We're only looking at associated type bounds
|
||||||
.filter(|item| item.kind == ty::AssocKind::Type)
|
.filter(|item| item.kind == ty::AssocKind::Type)
|
||||||
|
// Ignore GATs with `Self: Sized`
|
||||||
|
.filter(|item| !tcx.generics_require_sized_self(item.def_id))
|
||||||
.flat_map(|item| tcx.explicit_item_bounds(item.def_id).iter_identity_copied())
|
.flat_map(|item| tcx.explicit_item_bounds(item.def_id).iter_identity_copied())
|
||||||
.filter_map(|(clause, sp)| {
|
.filter_map(|(clause, sp)| {
|
||||||
// Item bounds *can* have self projections, since they never get
|
// Item bounds *can* have self projections, since they never get
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
// Ensure that we properly ignore the `B<Self>` associated type bound on `A::T`
|
||||||
|
// since that associated type requires `Self: Sized`.
|
||||||
|
|
||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
struct X(&'static dyn A);
|
||||||
|
|
||||||
|
trait A {
|
||||||
|
type T: B<Self> where Self: Sized;
|
||||||
|
}
|
||||||
|
|
||||||
|
trait B<T> {}
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
Add table
Add a link
Reference in a new issue