@@ -42,7 +42,7 @@ use hir_def::{
42
42
use hir_expand:: name:: Name ;
43
43
use la_arena:: { Arena , ArenaMap } ;
44
44
use rustc_hash:: FxHashSet ;
45
- use stdx:: { impl_from, never} ;
45
+ use stdx:: { TupleExt , impl_from, never} ;
46
46
use triomphe:: { Arc , ThinArc } ;
47
47
48
48
use crate :: {
@@ -588,16 +588,28 @@ impl<'a> TyLoweringContext<'a> {
588
588
clause = Some ( crate :: wrap_empty_binders ( WhereClause :: Implemented ( trait_ref) ) ) ;
589
589
}
590
590
}
591
+ // FIXME(sized-hierarchy)
591
592
& TypeBound :: Path ( path, TraitBoundModifier :: Maybe ) => {
592
593
let sized_trait = LangItem :: Sized . resolve_trait ( self . db , self . resolver . krate ( ) ) ;
593
594
// Don't lower associated type bindings as the only possible relaxed trait bound
594
595
// `?Sized` has no of them.
595
596
// 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 {
600
600
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)
601
613
}
602
614
}
603
615
& TypeBound :: Lifetime ( l) => {
@@ -910,6 +922,7 @@ pub(crate) fn field_types_with_diagnostics_query(
910
922
( Arc :: new ( res) , create_diagnostics ( ctx. diagnostics ) )
911
923
}
912
924
925
+ // FIXME(sized-hierarchy)
913
926
/// This query exists only to be used when resolving short-hand associated types
914
927
/// like `T::Item`.
915
928
///
@@ -1130,6 +1143,7 @@ pub(crate) fn generic_predicates_without_parent_with_diagnostics_query(
1130
1143
generic_predicates_filtered_by ( db, def, |_, d| d == def)
1131
1144
}
1132
1145
1146
+ // FIXME(sized-hierarchy)
1133
1147
/// Resolve the where clause(s) of an item with generics,
1134
1148
/// except the ones inherited from the parent
1135
1149
fn generic_predicates_filtered_by < F > (
@@ -1163,7 +1177,6 @@ where
1163
1177
for pred in maybe_parent_generics. where_predicates ( ) {
1164
1178
if filter ( pred, maybe_parent_generics. def ( ) ) {
1165
1179
// We deliberately use `generics` and not `maybe_parent_generics` here. This is not a mistake!
1166
- // If we use the parent generics
1167
1180
predicates. extend (
1168
1181
ctx. lower_where_predicate ( pred, false ) . map ( |p| make_binders ( db, & generics, p) ) ,
1169
1182
) ;
@@ -1190,6 +1203,7 @@ where
1190
1203
)
1191
1204
}
1192
1205
1206
+ // FIXME(sized-hierarchy)
1193
1207
/// Generate implicit `: Sized` predicates for all generics that has no `?Sized` bound.
1194
1208
/// Exception is Self of a trait def.
1195
1209
fn implicitly_sized_clauses < ' db , ' a , ' subst : ' a > (
0 commit comments