@@ -1475,7 +1475,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14751475 // keep track of the Span info. Now, `<dyn HirTyLowerer>::add_implicit_sized_bound`
14761476 // checks both param bounds and where clauses for `?Sized`.
14771477 for pred in & generics. where_clause . predicates {
1478- let WherePredicate :: BoundPredicate ( bound_pred) = pred else {
1478+ let WherePredicateKind :: BoundPredicate ( ref bound_pred) = pred. kind else {
14791479 continue ;
14801480 } ;
14811481 let compute_is_param = || {
@@ -1705,8 +1705,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
17051705 } ) ;
17061706 let span = self . lower_span ( span) ;
17071707
1708- match kind {
1709- GenericParamKind :: Const { .. } => None ,
1708+ let kind = match kind {
1709+ GenericParamKind :: Const { .. } => return None ,
17101710 GenericParamKind :: Type { .. } => {
17111711 let def_id = self . local_def_id ( id) . to_def_id ( ) ;
17121712 let hir_id = self . next_id ( ) ;
@@ -1721,37 +1721,40 @@ impl<'hir> LoweringContext<'_, 'hir> {
17211721 let ty_id = self . next_id ( ) ;
17221722 let bounded_ty =
17231723 self . ty_path ( ty_id, param_span, hir:: QPath :: Resolved ( None , ty_path) ) ;
1724- Some ( hir:: WherePredicate :: BoundPredicate ( hir:: WhereBoundPredicate {
1724+ hir:: WherePredicateKind :: BoundPredicate ( hir:: WhereBoundPredicate {
17251725 hir_id : self . next_id ( ) ,
17261726 bounded_ty : self . arena . alloc ( bounded_ty) ,
17271727 bounds,
17281728 span,
17291729 bound_generic_params : & [ ] ,
17301730 origin,
1731- } ) )
1731+ } )
17321732 }
17331733 GenericParamKind :: Lifetime => {
17341734 let ident = self . lower_ident ( ident) ;
17351735 let lt_id = self . next_node_id ( ) ;
17361736 let lifetime = self . new_named_lifetime ( id, lt_id, ident) ;
1737- Some ( hir:: WherePredicate :: RegionPredicate ( hir:: WhereRegionPredicate {
1737+ hir:: WherePredicateKind :: RegionPredicate ( hir:: WhereRegionPredicate {
17381738 lifetime,
17391739 span,
17401740 bounds,
17411741 in_where_clause : false ,
1742- } ) )
1742+ } )
17431743 }
1744- }
1744+ } ;
1745+ Some ( hir:: WherePredicate { hir_id : self . next_id ( ) , kind : self . arena . alloc ( kind) } )
17451746 }
17461747
17471748 fn lower_where_predicate ( & mut self , pred : & WherePredicate ) -> hir:: WherePredicate < ' hir > {
1748- match pred {
1749- WherePredicate :: BoundPredicate ( WhereBoundPredicate {
1749+ let hir_id = self . lower_node_id ( pred. id ) ;
1750+ self . lower_attrs ( hir_id, & pred. attrs ) ;
1751+ let kind = match & pred. kind {
1752+ WherePredicateKind :: BoundPredicate ( WhereBoundPredicate {
17501753 bound_generic_params,
17511754 bounded_ty,
17521755 bounds,
17531756 span,
1754- } ) => hir:: WherePredicate :: BoundPredicate ( hir:: WhereBoundPredicate {
1757+ } ) => hir:: WherePredicateKind :: BoundPredicate ( hir:: WhereBoundPredicate {
17551758 hir_id : self . next_id ( ) ,
17561759 bound_generic_params : self
17571760 . lower_generic_params ( bound_generic_params, hir:: GenericParamSource :: Binder ) ,
@@ -1764,26 +1767,30 @@ impl<'hir> LoweringContext<'_, 'hir> {
17641767 span : self . lower_span ( * span) ,
17651768 origin : PredicateOrigin :: WhereClause ,
17661769 } ) ,
1767- WherePredicate :: RegionPredicate ( WhereRegionPredicate { lifetime, bounds, span } ) => {
1768- hir:: WherePredicate :: RegionPredicate ( hir:: WhereRegionPredicate {
1769- span : self . lower_span ( * span) ,
1770- lifetime : self . lower_lifetime ( lifetime) ,
1771- bounds : self . lower_param_bounds (
1772- bounds,
1773- ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ,
1774- ) ,
1775- in_where_clause : true ,
1776- } )
1777- }
1778- WherePredicate :: EqPredicate ( WhereEqPredicate { lhs_ty, rhs_ty, span } ) => {
1779- hir:: WherePredicate :: EqPredicate ( hir:: WhereEqPredicate {
1770+ WherePredicateKind :: RegionPredicate ( WhereRegionPredicate {
1771+ lifetime,
1772+ bounds,
1773+ span,
1774+ } ) => hir:: WherePredicateKind :: RegionPredicate ( hir:: WhereRegionPredicate {
1775+ span : self . lower_span ( * span) ,
1776+ lifetime : self . lower_lifetime ( lifetime) ,
1777+ bounds : self . lower_param_bounds (
1778+ bounds,
1779+ ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ,
1780+ ) ,
1781+ in_where_clause : true ,
1782+ } ) ,
1783+ WherePredicateKind :: EqPredicate ( WhereEqPredicate { lhs_ty, rhs_ty, span } ) => {
1784+ hir:: WherePredicateKind :: EqPredicate ( hir:: WhereEqPredicate {
17801785 lhs_ty : self
17811786 . lower_ty ( lhs_ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ) ,
17821787 rhs_ty : self
17831788 . lower_ty ( rhs_ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ) ,
17841789 span : self . lower_span ( * span) ,
17851790 } )
17861791 }
1787- }
1792+ } ;
1793+ let kind = self . arena . alloc ( kind) ;
1794+ hir:: WherePredicate { hir_id, kind }
17881795 }
17891796}
0 commit comments