@@ -1321,12 +1321,17 @@ pub fn explicit_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1321
1321
let node = tcx. hir . get ( node_id) ;
1322
1322
1323
1323
let mut is_trait = None ;
1324
+ let mut is_trait_item = None ;
1324
1325
let mut is_default_impl_trait = None ;
1325
1326
1326
1327
let icx = ItemCtxt :: new ( tcx, def_id) ;
1327
1328
let no_generics = hir:: Generics :: empty ( ) ;
1328
1329
let ast_generics = match node {
1329
- NodeTraitItem ( item) => & item. generics ,
1330
+ NodeTraitItem ( item) => {
1331
+ is_trait_item = Some ( ( ) ) ;
1332
+ & item. generics
1333
+ }
1334
+
1330
1335
NodeImplItem ( item) => & item. generics ,
1331
1336
1332
1337
NodeItem ( item) => {
@@ -1401,13 +1406,37 @@ pub fn explicit_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1401
1406
// and the explicit where-clauses, but to get the full set of predicates
1402
1407
// on a trait we need to add in the supertrait bounds and bounds found on
1403
1408
// associated types.
1404
- if let Some ( ( trait_ref , _) ) = is_trait {
1409
+ if let Some ( ( _trait_ref , _) ) = is_trait {
1405
1410
predicates = tcx. super_predicates_of ( def_id) . predicates ;
1406
1411
1407
1412
// Add in a predicate that `Self:Trait` (where `Trait` is the
1408
1413
// current trait). This is needed for builtin bounds.
1409
- predicates. push ( trait_ref. to_poly_trait_ref ( ) . to_predicate ( ) ) ;
1414
+ //predicates.push(trait_ref.to_poly_trait_ref().to_predicate());
1415
+ }
1416
+
1417
+ if let Some ( ( ) ) = is_trait_item {
1418
+ let id = tcx. hir . as_local_node_id ( def_id) . unwrap ( ) ;
1419
+ debug ! ( "explicit_predicates_of: handling def_id={:?}, id={:?}" , def_id, id) ;
1420
+
1421
+ let parent_id = tcx. hir . get_parent ( id) ;
1422
+ let parent_def_id = tcx. hir . local_def_id ( parent_id) ;
1423
+ if let Some ( hir:: map:: NodeItem ( parent_item) ) = tcx. hir . find ( parent_id) {
1424
+ debug ! ( " explicit_predicates_of: has parent, node: {:?}" , parent_item. node) ;
1425
+ if let hir:: ItemTrait ( ..) = parent_item. node {
1426
+ debug ! ( " explicit_predicates_of: parent is trait!" ) ;
1427
+ let trait_ref = ty:: TraitRef {
1428
+ def_id : parent_def_id,
1429
+ substs : Substs :: identity_for_item ( tcx, parent_def_id)
1430
+ } ;
1431
+ predicates. push ( trait_ref. to_poly_trait_ref ( ) . to_predicate ( ) ) ;
1432
+ } else {
1433
+ debug ! ( " explicit_predicates_of: parent is not trait :((" ) ;
1434
+ }
1435
+ } else {
1436
+ debug ! ( " explicit_predicates_of: no parent :(" ) ;
1437
+ }
1410
1438
}
1439
+ debug ! ( "explicit_predicates_of: predicates={:?}" , predicates) ;
1411
1440
1412
1441
// In default impls, we can assume that the self type implements
1413
1442
// the trait. So in:
0 commit comments