@@ -42,7 +42,7 @@ use hir_def::{
4242use hir_expand:: name:: Name ;
4343use la_arena:: { Arena , ArenaMap } ;
4444use rustc_hash:: FxHashSet ;
45- use stdx:: { impl_from, never} ;
45+ use stdx:: { TupleExt , impl_from, never} ;
4646use triomphe:: { Arc , ThinArc } ;
4747
4848use crate :: {
@@ -588,16 +588,28 @@ impl<'a> TyLoweringContext<'a> {
588588 clause = Some ( crate :: wrap_empty_binders ( WhereClause :: Implemented ( trait_ref) ) ) ;
589589 }
590590 }
591+ // FIXME(sized-hierarchy)
591592 & TypeBound :: Path ( path, TraitBoundModifier :: Maybe ) => {
592593 let sized_trait = LangItem :: Sized . resolve_trait ( self . db , self . resolver . krate ( ) ) ;
593594 // Don't lower associated type bindings as the only possible relaxed trait bound
594595 // `?Sized` has no of them.
595596 // If we got another trait here ignore the bound completely.
596- let trait_id = self
597- . lower_trait_ref_from_path ( path, self_ty. clone ( ) )
598- . map ( |( trait_ref, _) | trait_ref. hir_trait_id ( ) ) ;
599- if trait_id == sized_trait {
597+ let trait_id =
598+ self . lower_trait_ref_from_path ( path, self_ty. clone ( ) ) . map ( TupleExt :: head) ;
599+ if trait_id. as_ref ( ) . map ( |trait_ref| trait_ref. hir_trait_id ( ) ) == sized_trait {
600600 self . unsized_types . insert ( self_ty) ;
601+ clause = trait_id
602+ . and_then ( |it| {
603+ Some ( TraitRef {
604+ trait_id : to_chalk_trait_id (
605+ LangItem :: MetaSized
606+ . resolve_trait ( self . db , self . resolver . krate ( ) ) ?,
607+ ) ,
608+ substitution : it. substitution ,
609+ } )
610+ } )
611+ . map ( WhereClause :: Implemented )
612+ . map ( crate :: wrap_empty_binders)
601613 }
602614 }
603615 & TypeBound :: Lifetime ( l) => {
@@ -910,6 +922,7 @@ pub(crate) fn field_types_with_diagnostics_query(
910922 ( Arc :: new ( res) , create_diagnostics ( ctx. diagnostics ) )
911923}
912924
925+ // FIXME(sized-hierarchy)
913926/// This query exists only to be used when resolving short-hand associated types
914927/// like `T::Item`.
915928///
@@ -1130,6 +1143,7 @@ pub(crate) fn generic_predicates_without_parent_with_diagnostics_query(
11301143 generic_predicates_filtered_by ( db, def, |_, d| d == def)
11311144}
11321145
1146+ // FIXME(sized-hierarchy)
11331147/// Resolve the where clause(s) of an item with generics,
11341148/// except the ones inherited from the parent
11351149fn generic_predicates_filtered_by < F > (
@@ -1163,7 +1177,6 @@ where
11631177 for pred in maybe_parent_generics. where_predicates ( ) {
11641178 if filter ( pred, maybe_parent_generics. def ( ) ) {
11651179 // We deliberately use `generics` and not `maybe_parent_generics` here. This is not a mistake!
1166- // If we use the parent generics
11671180 predicates. extend (
11681181 ctx. lower_where_predicate ( pred, false ) . map ( |p| make_binders ( db, & generics, p) ) ,
11691182 ) ;
@@ -1190,6 +1203,7 @@ where
11901203 )
11911204}
11921205
1206+ // FIXME(sized-hierarchy)
11931207/// Generate implicit `: Sized` predicates for all generics that has no `?Sized` bound.
11941208/// Exception is Self of a trait def.
11951209fn implicitly_sized_clauses < ' db , ' a , ' subst : ' a > (
0 commit comments