@@ -185,11 +185,12 @@ use rustc_ast::ptr::P;
185
185
use rustc_ast:: { self as ast, BinOpKind , EnumDef , Expr , Generics , PatKind } ;
186
186
use rustc_ast:: { GenericArg , GenericParamKind , VariantData } ;
187
187
use rustc_attr as attr;
188
+ use rustc_data_structures:: fx:: FxHashSet ;
188
189
use rustc_data_structures:: map_in_place:: MapInPlace ;
189
190
use rustc_expand:: base:: { Annotatable , ExtCtxt } ;
190
191
use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
191
192
use rustc_span:: Span ;
192
- use smallvec:: SmallVec ;
193
+ use smallvec:: { smallvec , SmallVec } ;
193
194
194
195
use ty:: { Bounds , Path , Ptr , PtrTy , Self_ , Ty } ;
195
196
@@ -668,20 +669,23 @@ impl<'a> TraitDef<'a> {
668
669
669
670
if ty_params. peek ( ) . is_some ( ) {
670
671
let ty_param_names: Vec < Symbol > =
671
- ty_params. map ( |ty_param| ty_param. ident . name ) . collect ( ) ;
672
+ ty_params. clone ( ) . map ( |ty_param| ty_param. ident . name ) . collect ( ) ;
673
+
674
+ let mut seen_simple_field_ty_params: FxHashSet < _ > =
675
+ ty_params. map ( |ty_param| smallvec ! [ ty_param. ident] ) . collect ( ) ;
672
676
673
677
for field_ty in field_tys {
674
678
let field_ty_params = find_type_parameters ( & field_ty, & ty_param_names, cx) ;
675
679
676
680
for field_ty_param in field_ty_params {
677
681
// if we have already handled this type, skip it
678
- if let ast:: TyKind :: Path ( _, ref p) = field_ty_param. ty . kind {
679
- if p. segments . len ( ) == 1
680
- && ty_param_names. contains ( & p. segments [ 0 ] . ident . name )
681
- {
682
+ if let Some ( field_ty_param_path) = field_ty_param. to_simple_path ( ) {
683
+ let changed = seen_simple_field_ty_params. insert ( field_ty_param_path) ;
684
+ if !changed {
682
685
continue ;
683
- } ;
686
+ }
684
687
}
688
+
685
689
let mut bounds: Vec < _ > = self
686
690
. additional_bounds
687
691
. iter ( )
0 commit comments