@@ -58,6 +58,8 @@ use rustc::hir::{self, CodegenFnAttrFlags, CodegenFnAttrs, Unsafety};
58
58
59
59
use std:: iter;
60
60
61
+ struct OnlySelfBounds ( bool ) ;
62
+
61
63
///////////////////////////////////////////////////////////////////////////
62
64
// Main entry point
63
65
@@ -331,7 +333,7 @@ impl<'a, 'tcx> ItemCtxt<'a, 'tcx> {
331
333
ast_generics : & hir:: Generics ,
332
334
param_id : ast:: NodeId ,
333
335
ty : Ty < ' tcx > ,
334
- only_self_bounds : bool ,
336
+ only_self_bounds : OnlySelfBounds ,
335
337
) -> Vec < ( ty:: Predicate < ' tcx > , Span ) > {
336
338
let from_ty_params = ast_generics
337
339
. params
@@ -354,12 +356,10 @@ impl<'a, 'tcx> ItemCtxt<'a, 'tcx> {
354
356
. flat_map ( |bp| {
355
357
let bt = if is_param ( self . tcx , & bp. bounded_ty , param_id) {
356
358
Some ( ty)
359
+ } else if only_self_bounds. 0 {
360
+ None
357
361
} 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 ) )
363
363
} ;
364
364
bp. bounds . iter ( ) . filter_map ( move |b| {
365
365
if let Some ( bt) = bt { Some ( ( bt, b) ) } else { None }
@@ -710,7 +710,10 @@ fn super_predicates_of<'a, 'tcx>(
710
710
let superbounds1 = superbounds1. predicates ( tcx, self_param_ty) ;
711
711
712
712
// 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".
714
717
let is_trait_alias = ty:: is_trait_alias ( tcx, trait_def_id) ;
715
718
let superbounds2 = icx. type_parameter_bounds_in_generics (
716
719
generics, item. id , self_param_ty, !is_trait_alias) ;
0 commit comments