@@ -58,6 +58,8 @@ use rustc::hir::{self, CodegenFnAttrFlags, CodegenFnAttrs, Unsafety};
5858
5959use std:: iter;
6060
61+ struct OnlySelfBounds ( bool ) ;
62+
6163///////////////////////////////////////////////////////////////////////////
6264// Main entry point
6365
@@ -331,7 +333,7 @@ impl<'a, 'tcx> ItemCtxt<'a, 'tcx> {
331333 ast_generics : & hir:: Generics ,
332334 param_id : ast:: NodeId ,
333335 ty : Ty < ' tcx > ,
334- only_self_bounds : bool ,
336+ only_self_bounds : OnlySelfBounds ,
335337 ) -> Vec < ( ty:: Predicate < ' tcx > , Span ) > {
336338 let from_ty_params = ast_generics
337339 . params
@@ -354,12 +356,10 @@ impl<'a, 'tcx> ItemCtxt<'a, 'tcx> {
354356 . flat_map ( |bp| {
355357 let bt = if is_param ( self . tcx , & bp. bounded_ty , param_id) {
356358 Some ( ty)
359+ } else if only_self_bounds. 0 {
360+ None
357361 } else {
358- if only_self_bounds {
359- None
360- } else {
361- Some ( self . to_ty ( & bp. bounded_ty ) )
362- }
362+ Some ( self . to_ty ( & bp. bounded_ty ) )
363363 } ;
364364 bp. bounds . iter ( ) . filter_map ( move |b| {
365365 if let Some ( bt) = bt { Some ( ( bt, b) ) } else { None }
@@ -710,7 +710,10 @@ fn super_predicates_of<'a, 'tcx>(
710710 let superbounds1 = superbounds1. predicates ( tcx, self_param_ty) ;
711711
712712 // Convert any explicit superbounds in the where clause,
713- // e.g. `trait Foo where Self : Bar`:
713+ // e.g. `trait Foo where Self : Bar`.
714+ // In the case of trait aliases, however, we include all bounds in the where clause,
715+ // so e.g. `trait Foo = where u32: PartialEq<Self>` would include `u32: PartialEq<Self>`
716+ // as one of its "superpredicates".
714717 let is_trait_alias = ty:: is_trait_alias ( tcx, trait_def_id) ;
715718 let superbounds2 = icx. type_parameter_bounds_in_generics (
716719 generics, item. id , self_param_ty, !is_trait_alias) ;
0 commit comments