@@ -695,65 +695,61 @@ impl<'a> TraitDef<'a> {
695695 }
696696 } ) ) ;
697697
698- {
699- // Extra scope required here so ty_params goes out of scope before params is moved
700-
701- let mut ty_params = params
702- . iter ( )
703- . filter ( |param| matches ! ( param. kind, ast:: GenericParamKind :: Type { .. } ) )
704- . peekable ( ) ;
705-
706- if ty_params. peek ( ) . is_some ( ) {
707- let ty_param_names: Vec < Symbol > =
708- ty_params. map ( |ty_param| ty_param. ident . name ) . collect ( ) ;
709-
710- for field_ty in field_tys {
711- let field_ty_params = find_type_parameters ( & field_ty, & ty_param_names, cx) ;
712-
713- for field_ty_param in field_ty_params {
714- // if we have already handled this type, skip it
715- if let ast:: TyKind :: Path ( _, p) = & field_ty_param. ty . kind
716- && let [ sole_segment] = & * p. segments
717- && ty_param_names. contains ( & sole_segment. ident . name )
718- {
719- continue ;
720- }
721- let mut bounds: Vec < _ > = self
722- . additional_bounds
723- . iter ( )
724- . map ( |p| {
725- cx. trait_bound (
726- p. to_path ( cx, self . span , type_ident, generics) ,
727- self . is_const ,
728- )
729- } )
730- . collect ( ) ;
731-
732- // Require the current trait.
733- if !self . skip_path_as_bound {
734- bounds. push ( cx. trait_bound ( trait_path. clone ( ) , self . is_const ) ) ;
735- }
736-
737- // Add a `Copy` bound if required.
738- if is_packed && self . needs_copy_as_bound_if_packed {
739- let p = deriving:: path_std!( marker:: Copy ) ;
740- bounds. push ( cx. trait_bound (
698+ let mut ty_params = params
699+ . iter ( )
700+ . filter ( |param| matches ! ( param. kind, ast:: GenericParamKind :: Type { .. } ) )
701+ . peekable ( ) ;
702+
703+ if ty_params. peek ( ) . is_some ( ) {
704+ let ty_param_names: Vec < Symbol > =
705+ ty_params. map ( |ty_param| ty_param. ident . name ) . collect ( ) ;
706+
707+ for field_ty in field_tys {
708+ let field_ty_params = find_type_parameters ( & field_ty, & ty_param_names, cx) ;
709+
710+ for field_ty_param in field_ty_params {
711+ // if we have already handled this type, skip it
712+ if let ast:: TyKind :: Path ( _, p) = & field_ty_param. ty . kind
713+ && let [ sole_segment] = & * p. segments
714+ && ty_param_names. contains ( & sole_segment. ident . name )
715+ {
716+ continue ;
717+ }
718+ let mut bounds: Vec < _ > = self
719+ . additional_bounds
720+ . iter ( )
721+ . map ( |p| {
722+ cx. trait_bound (
741723 p. to_path ( cx, self . span , type_ident, generics) ,
742724 self . is_const ,
743- ) ) ;
744- }
725+ )
726+ } )
727+ . collect ( ) ;
745728
746- if !bounds. is_empty ( ) {
747- let predicate = ast:: WhereBoundPredicate {
748- span : self . span ,
749- bound_generic_params : field_ty_param. bound_generic_params ,
750- bounded_ty : field_ty_param. ty ,
751- bounds,
752- } ;
729+ // Require the current trait.
730+ if !self . skip_path_as_bound {
731+ bounds. push ( cx. trait_bound ( trait_path. clone ( ) , self . is_const ) ) ;
732+ }
753733
754- let predicate = ast:: WherePredicate :: BoundPredicate ( predicate) ;
755- where_clause. predicates . push ( predicate) ;
756- }
734+ // Add a `Copy` bound if required.
735+ if is_packed && self . needs_copy_as_bound_if_packed {
736+ let p = deriving:: path_std!( marker:: Copy ) ;
737+ bounds. push ( cx. trait_bound (
738+ p. to_path ( cx, self . span , type_ident, generics) ,
739+ self . is_const ,
740+ ) ) ;
741+ }
742+
743+ if !bounds. is_empty ( ) {
744+ let predicate = ast:: WhereBoundPredicate {
745+ span : self . span ,
746+ bound_generic_params : field_ty_param. bound_generic_params ,
747+ bounded_ty : field_ty_param. ty ,
748+ bounds,
749+ } ;
750+
751+ let predicate = ast:: WherePredicate :: BoundPredicate ( predicate) ;
752+ where_clause. predicates . push ( predicate) ;
757753 }
758754 }
759755 }
0 commit comments