@@ -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,38 +1554,38 @@ 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 {
1558
- hir_id : self . next_id ( ) ,
1557
+ hir:: WherePredicateKind :: BoundPredicate ( hir:: WhereBoundPredicate {
1559
1558
bounded_ty : self . arena . alloc ( bounded_ty) ,
1560
1559
bounds,
1561
1560
span,
1562
1561
bound_generic_params : & [ ] ,
1563
1562
origin,
1564
- } ) )
1563
+ } )
1565
1564
}
1566
1565
GenericParamKind :: Lifetime => {
1567
1566
let ident = self . lower_ident ( ident) ;
1568
1567
let lt_id = self . next_node_id ( ) ;
1569
1568
let lifetime = self . new_named_lifetime ( id, lt_id, ident) ;
1570
- Some ( hir:: WherePredicate :: RegionPredicate ( hir:: WhereRegionPredicate {
1569
+ hir:: WherePredicateKind :: RegionPredicate ( hir:: WhereRegionPredicate {
1571
1570
lifetime,
1572
1571
span,
1573
1572
bounds,
1574
1573
in_where_clause : false ,
1575
- } ) )
1574
+ } )
1576
1575
}
1577
- }
1576
+ } ;
1577
+ Some ( hir:: WherePredicate { hir_id : self . next_id ( ) , kind : self . arena . alloc ( kind) , span } )
1578
1578
}
1579
1579
1580
1580
fn lower_where_predicate ( & mut self , pred : & WherePredicate ) -> hir:: WherePredicate < ' hir > {
1581
- match pred {
1582
- WherePredicate :: BoundPredicate ( WhereBoundPredicate {
1581
+ let hir_id = self . lower_node_id ( pred. id ) ;
1582
+ let kind = match & pred. kind {
1583
+ WherePredicateKind :: BoundPredicate ( WhereBoundPredicate {
1583
1584
bound_generic_params,
1584
1585
bounded_ty,
1585
1586
bounds,
1586
1587
span,
1587
- } ) => hir:: WherePredicate :: BoundPredicate ( hir:: WhereBoundPredicate {
1588
- hir_id : self . next_id ( ) ,
1588
+ } ) => hir:: WherePredicateKind :: BoundPredicate ( hir:: WhereBoundPredicate {
1589
1589
bound_generic_params : self
1590
1590
. lower_generic_params ( bound_generic_params, hir:: GenericParamSource :: Binder ) ,
1591
1591
bounded_ty : self
@@ -1597,26 +1597,31 @@ impl<'hir> LoweringContext<'_, 'hir> {
1597
1597
span : self . lower_span ( * span) ,
1598
1598
origin : PredicateOrigin :: WhereClause ,
1599
1599
} ) ,
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 {
1600
+ WherePredicateKind :: RegionPredicate ( WhereRegionPredicate {
1601
+ lifetime,
1602
+ bounds,
1603
+ span,
1604
+ } ) => hir:: WherePredicateKind :: RegionPredicate ( hir:: WhereRegionPredicate {
1605
+ span : self . lower_span ( * span) ,
1606
+ lifetime : self . lower_lifetime ( lifetime) ,
1607
+ bounds : self . lower_param_bounds (
1608
+ bounds,
1609
+ ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ,
1610
+ ) ,
1611
+ in_where_clause : true ,
1612
+ } ) ,
1613
+ WherePredicateKind :: EqPredicate ( WhereEqPredicate { lhs_ty, rhs_ty, span } ) => {
1614
+ hir:: WherePredicateKind :: EqPredicate ( hir:: WhereEqPredicate {
1613
1615
lhs_ty : self
1614
1616
. lower_ty ( lhs_ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ) ,
1615
1617
rhs_ty : self
1616
1618
. lower_ty ( rhs_ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ) ,
1617
1619
span : self . lower_span ( * span) ,
1618
1620
} )
1619
1621
}
1620
- }
1622
+ } ;
1623
+ let kind = self . arena . alloc ( kind) ;
1624
+ let span = self . lower_span ( pred. span ) ;
1625
+ hir:: WherePredicate { hir_id, kind, span }
1621
1626
}
1622
1627
}
0 commit comments