@@ -1475,7 +1475,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1475
1475
// keep track of the Span info. Now, `<dyn HirTyLowerer>::add_implicit_sized_bound`
1476
1476
// checks both param bounds and where clauses for `?Sized`.
1477
1477
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 {
1479
1479
continue ;
1480
1480
} ;
1481
1481
let compute_is_param = || {
@@ -1705,8 +1705,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
1705
1705
} ) ;
1706
1706
let span = self . lower_span ( span) ;
1707
1707
1708
- match kind {
1709
- GenericParamKind :: Const { .. } => None ,
1708
+ let kind = match kind {
1709
+ GenericParamKind :: Const { .. } => return None ,
1710
1710
GenericParamKind :: Type { .. } => {
1711
1711
let def_id = self . local_def_id ( id) . to_def_id ( ) ;
1712
1712
let hir_id = self . next_id ( ) ;
@@ -1721,37 +1721,40 @@ impl<'hir> LoweringContext<'_, 'hir> {
1721
1721
let ty_id = self . next_id ( ) ;
1722
1722
let bounded_ty =
1723
1723
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 {
1725
1725
hir_id : self . next_id ( ) ,
1726
1726
bounded_ty : self . arena . alloc ( bounded_ty) ,
1727
1727
bounds,
1728
1728
span,
1729
1729
bound_generic_params : & [ ] ,
1730
1730
origin,
1731
- } ) )
1731
+ } )
1732
1732
}
1733
1733
GenericParamKind :: Lifetime => {
1734
1734
let ident = self . lower_ident ( ident) ;
1735
1735
let lt_id = self . next_node_id ( ) ;
1736
1736
let lifetime = self . new_named_lifetime ( id, lt_id, ident) ;
1737
- Some ( hir:: WherePredicate :: RegionPredicate ( hir:: WhereRegionPredicate {
1737
+ hir:: WherePredicateKind :: RegionPredicate ( hir:: WhereRegionPredicate {
1738
1738
lifetime,
1739
1739
span,
1740
1740
bounds,
1741
1741
in_where_clause : false ,
1742
- } ) )
1742
+ } )
1743
1743
}
1744
- }
1744
+ } ;
1745
+ Some ( hir:: WherePredicate { hir_id : self . next_id ( ) , kind : self . arena . alloc ( kind) } )
1745
1746
}
1746
1747
1747
1748
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 {
1750
1753
bound_generic_params,
1751
1754
bounded_ty,
1752
1755
bounds,
1753
1756
span,
1754
- } ) => hir:: WherePredicate :: BoundPredicate ( hir:: WhereBoundPredicate {
1757
+ } ) => hir:: WherePredicateKind :: BoundPredicate ( hir:: WhereBoundPredicate {
1755
1758
hir_id : self . next_id ( ) ,
1756
1759
bound_generic_params : self
1757
1760
. lower_generic_params ( bound_generic_params, hir:: GenericParamSource :: Binder ) ,
@@ -1764,26 +1767,30 @@ impl<'hir> LoweringContext<'_, 'hir> {
1764
1767
span : self . lower_span ( * span) ,
1765
1768
origin : PredicateOrigin :: WhereClause ,
1766
1769
} ) ,
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 {
1780
1785
lhs_ty : self
1781
1786
. lower_ty ( lhs_ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ) ,
1782
1787
rhs_ty : self
1783
1788
. lower_ty ( rhs_ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ) ,
1784
1789
span : self . lower_span ( * span) ,
1785
1790
} )
1786
1791
}
1787
- }
1792
+ } ;
1793
+ let kind = self . arena . alloc ( kind) ;
1794
+ hir:: WherePredicate { hir_id, kind }
1788
1795
}
1789
1796
}
0 commit comments