File tree 1 file changed +11
-0
lines changed
src/libsyntax/ext/deriving/generic
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -188,6 +188,7 @@ pub use self::SubstructureFields::*;
188
188
use self :: StructType :: * ;
189
189
190
190
use std:: cell:: RefCell ;
191
+ use std:: collections:: HashSet ;
191
192
use std:: vec;
192
193
193
194
use abi:: Abi ;
@@ -549,10 +550,20 @@ impl<'a> TraitDef<'a> {
549
550
. map ( |ty_param| ty_param. ident . name )
550
551
. collect ( ) ;
551
552
553
+ let mut processed_field_types = HashSet :: new ( ) ;
552
554
for field_ty in field_tys {
553
555
let tys = find_type_parameters ( & * field_ty, & ty_param_names) ;
554
556
555
557
for ty in tys {
558
+ // if we have already handled this type, skip it
559
+ if let ast:: TyPath ( _, ref p) = ty. node {
560
+ if p. segments . len ( ) == 1
561
+ && ty_param_names. contains ( & p. segments [ 0 ] . identifier . name )
562
+ || processed_field_types. contains ( & p. segments ) {
563
+ continue ;
564
+ } ;
565
+ processed_field_types. insert ( p. segments . clone ( ) ) ;
566
+ }
556
567
let mut bounds: Vec < _ > = self . additional_bounds . iter ( ) . map ( |p| {
557
568
cx. typarambound ( p. to_path ( cx, self . span , type_ident, generics) )
558
569
} ) . collect ( ) ;
You can’t perform that action at this time.
0 commit comments