@@ -1046,12 +1046,12 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1046
1046
tcx. mk_fn_def ( def_id, substs)
1047
1047
}
1048
1048
ImplItemKind :: Const ( ref ty, _) => icx. to_ty ( ty) ,
1049
- ImplItemKind :: Existential ( ref _bounds ) => {
1049
+ ImplItemKind :: Existential ( _ ) => {
1050
1050
if tcx. impl_trait_ref ( tcx. hir . get_parent_did ( node_id) ) . is_none ( ) {
1051
1051
report_assoc_ty_on_inherent_impl ( tcx, item. span ) ;
1052
1052
}
1053
- // FIXME(oli-obk) implement existential types in trait impls
1054
- unimplemented ! ( )
1053
+
1054
+ find_existential_constraints ( tcx , def_id )
1055
1055
}
1056
1056
ImplItemKind :: Type ( ref ty) => {
1057
1057
if tcx. impl_trait_ref ( tcx. hir . get_parent_did ( node_id) ) . is_none ( ) {
@@ -1186,8 +1186,10 @@ fn find_existential_constraints<'a, 'tcx>(
1186
1186
}
1187
1187
impl < ' a , ' tcx > ConstraintLocator < ' a , ' tcx > {
1188
1188
fn check ( & mut self , def_id : DefId ) {
1189
+ trace ! ( "checking {:?}" , def_id) ;
1189
1190
// don't try to check items that cannot possibly constrain the type
1190
1191
if !self . tcx . has_typeck_tables ( def_id) {
1192
+ trace ! ( "no typeck tables for {:?}" , def_id) ;
1191
1193
return ;
1192
1194
}
1193
1195
let ty = self
@@ -1244,9 +1246,11 @@ fn find_existential_constraints<'a, 'tcx>(
1244
1246
let mut locator = ConstraintLocator { def_id, tcx, found : None } ;
1245
1247
let node_id = tcx. hir . as_local_node_id ( def_id) . unwrap ( ) ;
1246
1248
let parent = tcx. hir . get_parent ( node_id) ;
1249
+ trace ! ( "parent_id: {:?}" , parent) ;
1247
1250
if parent == ast:: CRATE_NODE_ID {
1248
1251
intravisit:: walk_crate ( & mut locator, tcx. hir . krate ( ) ) ;
1249
1252
} else {
1253
+ trace ! ( "parent: {:?}" , tcx. hir. get( parent) ) ;
1250
1254
match tcx. hir . get ( parent) {
1251
1255
NodeItem ( ref it) => intravisit:: walk_item ( & mut locator, it) ,
1252
1256
NodeImplItem ( ref it) => intravisit:: walk_impl_item ( & mut locator, it) ,
@@ -1485,7 +1489,23 @@ fn explicit_predicates_of<'a, 'tcx>(
1485
1489
& item. generics
1486
1490
}
1487
1491
1488
- NodeImplItem ( item) => & item. generics ,
1492
+ NodeImplItem ( item) => match item. node {
1493
+ ImplItemKind :: Existential ( ref bounds) => {
1494
+ let substs = Substs :: identity_for_item ( tcx, def_id) ;
1495
+ let anon_ty = tcx. mk_anon ( def_id, substs) ;
1496
+
1497
+ // Collect the bounds, i.e. the `A+B+'c` in `impl A+B+'c`.
1498
+ let bounds = compute_bounds ( & icx,
1499
+ anon_ty,
1500
+ bounds,
1501
+ SizedByDefault :: Yes ,
1502
+ tcx. def_span ( def_id) ) ;
1503
+
1504
+ predicates. extend ( bounds. predicates ( tcx, anon_ty) ) ;
1505
+ & item. generics
1506
+ } ,
1507
+ _ => & item. generics ,
1508
+ }
1489
1509
1490
1510
NodeItem ( item) => {
1491
1511
match item. node {
0 commit comments