@@ -1046,12 +1046,12 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
10461046 tcx. mk_fn_def ( def_id, substs)
10471047 }
10481048 ImplItemKind :: Const ( ref ty, _) => icx. to_ty ( ty) ,
1049- ImplItemKind :: Existential ( ref _bounds ) => {
1049+ ImplItemKind :: Existential ( _ ) => {
10501050 if tcx. impl_trait_ref ( tcx. hir . get_parent_did ( node_id) ) . is_none ( ) {
10511051 report_assoc_ty_on_inherent_impl ( tcx, item. span ) ;
10521052 }
1053- // FIXME(oli-obk) implement existential types in trait impls
1054- unimplemented ! ( )
1053+
1054+ find_existential_constraints ( tcx , def_id )
10551055 }
10561056 ImplItemKind :: Type ( ref ty) => {
10571057 if tcx. impl_trait_ref ( tcx. hir . get_parent_did ( node_id) ) . is_none ( ) {
@@ -1186,8 +1186,10 @@ fn find_existential_constraints<'a, 'tcx>(
11861186 }
11871187 impl < ' a , ' tcx > ConstraintLocator < ' a , ' tcx > {
11881188 fn check ( & mut self , def_id : DefId ) {
1189+ trace ! ( "checking {:?}" , def_id) ;
11891190 // don't try to check items that cannot possibly constrain the type
11901191 if !self . tcx . has_typeck_tables ( def_id) {
1192+ trace ! ( "no typeck tables for {:?}" , def_id) ;
11911193 return ;
11921194 }
11931195 let ty = self
@@ -1244,9 +1246,11 @@ fn find_existential_constraints<'a, 'tcx>(
12441246 let mut locator = ConstraintLocator { def_id, tcx, found : None } ;
12451247 let node_id = tcx. hir . as_local_node_id ( def_id) . unwrap ( ) ;
12461248 let parent = tcx. hir . get_parent ( node_id) ;
1249+ trace ! ( "parent_id: {:?}" , parent) ;
12471250 if parent == ast:: CRATE_NODE_ID {
12481251 intravisit:: walk_crate ( & mut locator, tcx. hir . krate ( ) ) ;
12491252 } else {
1253+ trace ! ( "parent: {:?}" , tcx. hir. get( parent) ) ;
12501254 match tcx. hir . get ( parent) {
12511255 NodeItem ( ref it) => intravisit:: walk_item ( & mut locator, it) ,
12521256 NodeImplItem ( ref it) => intravisit:: walk_impl_item ( & mut locator, it) ,
@@ -1485,7 +1489,23 @@ fn explicit_predicates_of<'a, 'tcx>(
14851489 & item. generics
14861490 }
14871491
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+ }
14891509
14901510 NodeItem ( item) => {
14911511 match item. node {
0 commit comments