@@ -1400,7 +1400,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1400
1400
// keep track of the Span info. Now, `<dyn HirTyLowerer>::add_implicit_sized_bound`
1401
1401
// checks both param bounds and where clauses for `?Sized`.
1402
1402
for pred in & generics. where_clause . predicates {
1403
- let WherePredicate :: BoundPredicate ( bound_pred) = pred else {
1403
+ let WherePredicateKind :: BoundPredicate ( ref bound_pred) = pred. kind else {
1404
1404
continue ;
1405
1405
} ;
1406
1406
let compute_is_param = || {
@@ -1538,8 +1538,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
1538
1538
} ) ;
1539
1539
let span = self . lower_span ( span) ;
1540
1540
1541
- match kind {
1542
- GenericParamKind :: Const { .. } => None ,
1541
+ let kind = match kind {
1542
+ GenericParamKind :: Const { .. } => return None ,
1543
1543
GenericParamKind :: Type { .. } => {
1544
1544
let def_id = self . local_def_id ( id) . to_def_id ( ) ;
1545
1545
let hir_id = self . next_id ( ) ;
@@ -1554,37 +1554,40 @@ impl<'hir> LoweringContext<'_, 'hir> {
1554
1554
let ty_id = self . next_id ( ) ;
1555
1555
let bounded_ty =
1556
1556
self . ty_path ( ty_id, param_span, hir:: QPath :: Resolved ( None , ty_path) ) ;
1557
- Some ( hir:: WherePredicate :: BoundPredicate ( hir:: WhereBoundPredicate {
1557
+ hir:: WherePredicateKind :: BoundPredicate ( hir:: WhereBoundPredicate {
1558
1558
hir_id : self . next_id ( ) ,
1559
1559
bounded_ty : self . arena . alloc ( bounded_ty) ,
1560
1560
bounds,
1561
1561
span,
1562
1562
bound_generic_params : & [ ] ,
1563
1563
origin,
1564
- } ) )
1564
+ } )
1565
1565
}
1566
1566
GenericParamKind :: Lifetime => {
1567
1567
let ident = self . lower_ident ( ident) ;
1568
1568
let lt_id = self . next_node_id ( ) ;
1569
1569
let lifetime = self . new_named_lifetime ( id, lt_id, ident) ;
1570
- Some ( hir:: WherePredicate :: RegionPredicate ( hir:: WhereRegionPredicate {
1570
+ hir:: WherePredicateKind :: RegionPredicate ( hir:: WhereRegionPredicate {
1571
1571
lifetime,
1572
1572
span,
1573
1573
bounds,
1574
1574
in_where_clause : false ,
1575
- } ) )
1575
+ } )
1576
1576
}
1577
- }
1577
+ } ;
1578
+ Some ( hir:: WherePredicate { hir_id : self . next_id ( ) , kind : self . arena . alloc ( kind) } )
1578
1579
}
1579
1580
1580
1581
fn lower_where_predicate ( & mut self , pred : & WherePredicate ) -> hir:: WherePredicate < ' hir > {
1581
- match pred {
1582
- WherePredicate :: BoundPredicate ( WhereBoundPredicate {
1582
+ let hir_id = self . lower_node_id ( pred. id ) ;
1583
+ self . lower_attrs ( hir_id, & pred. attrs ) ;
1584
+ let kind = match & pred. kind {
1585
+ WherePredicateKind :: BoundPredicate ( WhereBoundPredicate {
1583
1586
bound_generic_params,
1584
1587
bounded_ty,
1585
1588
bounds,
1586
1589
span,
1587
- } ) => hir:: WherePredicate :: BoundPredicate ( hir:: WhereBoundPredicate {
1590
+ } ) => hir:: WherePredicateKind :: BoundPredicate ( hir:: WhereBoundPredicate {
1588
1591
hir_id : self . next_id ( ) ,
1589
1592
bound_generic_params : self
1590
1593
. lower_generic_params ( bound_generic_params, hir:: GenericParamSource :: Binder ) ,
@@ -1597,26 +1600,30 @@ impl<'hir> LoweringContext<'_, 'hir> {
1597
1600
span : self . lower_span ( * span) ,
1598
1601
origin : PredicateOrigin :: WhereClause ,
1599
1602
} ) ,
1600
- WherePredicate :: RegionPredicate ( WhereRegionPredicate { lifetime, bounds, span } ) => {
1601
- hir:: WherePredicate :: RegionPredicate ( hir:: WhereRegionPredicate {
1602
- span : self . lower_span ( * span) ,
1603
- lifetime : self . lower_lifetime ( lifetime) ,
1604
- bounds : self . lower_param_bounds (
1605
- bounds,
1606
- ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ,
1607
- ) ,
1608
- in_where_clause : true ,
1609
- } )
1610
- }
1611
- WherePredicate :: EqPredicate ( WhereEqPredicate { lhs_ty, rhs_ty, span } ) => {
1612
- hir:: WherePredicate :: EqPredicate ( hir:: WhereEqPredicate {
1603
+ WherePredicateKind :: RegionPredicate ( WhereRegionPredicate {
1604
+ lifetime,
1605
+ bounds,
1606
+ span,
1607
+ } ) => hir:: WherePredicateKind :: RegionPredicate ( hir:: WhereRegionPredicate {
1608
+ span : self . lower_span ( * span) ,
1609
+ lifetime : self . lower_lifetime ( lifetime) ,
1610
+ bounds : self . lower_param_bounds (
1611
+ bounds,
1612
+ ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ,
1613
+ ) ,
1614
+ in_where_clause : true ,
1615
+ } ) ,
1616
+ WherePredicateKind :: EqPredicate ( WhereEqPredicate { lhs_ty, rhs_ty, span } ) => {
1617
+ hir:: WherePredicateKind :: EqPredicate ( hir:: WhereEqPredicate {
1613
1618
lhs_ty : self
1614
1619
. lower_ty ( lhs_ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ) ,
1615
1620
rhs_ty : self
1616
1621
. lower_ty ( rhs_ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ) ,
1617
1622
span : self . lower_span ( * span) ,
1618
1623
} )
1619
1624
}
1620
- }
1625
+ } ;
1626
+ let kind = self . arena . alloc ( kind) ;
1627
+ hir:: WherePredicate { hir_id, kind }
1621
1628
}
1622
1629
}
0 commit comments