@@ -185,11 +185,12 @@ use rustc_ast::ptr::P;
185185use rustc_ast:: { self as ast, BinOpKind , EnumDef , Expr , Generics , PatKind } ;
186186use rustc_ast:: { GenericArg , GenericParamKind , VariantData } ;
187187use rustc_attr as attr;
188+ use rustc_data_structures:: fx:: FxHashSet ;
188189use rustc_data_structures:: map_in_place:: MapInPlace ;
189190use rustc_expand:: base:: { Annotatable , ExtCtxt } ;
190191use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
191192use rustc_span:: Span ;
192- use smallvec:: SmallVec ;
193+ use smallvec:: { smallvec , SmallVec } ;
193194
194195use ty:: { Bounds , Path , Ptr , PtrTy , Self_ , Ty } ;
195196
@@ -668,20 +669,23 @@ impl<'a> TraitDef<'a> {
668669
669670 if ty_params. peek ( ) . is_some ( ) {
670671 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 ( ) ;
672676
673677 for field_ty in field_tys {
674678 let field_ty_params = find_type_parameters ( & field_ty, & ty_param_names, cx) ;
675679
676680 for field_ty_param in field_ty_params {
677681 // 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 {
682685 continue ;
683- } ;
686+ }
684687 }
688+
685689 let mut bounds: Vec < _ > = self
686690 . additional_bounds
687691 . iter ( )
0 commit comments