@@ -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,39 @@ 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
+ self.lower_attrs(hir_id, &pred.attrs);
1583
+ let kind = match &pred.kind {
1584
+ WherePredicateKind::BoundPredicate(WhereBoundPredicate {
1583
1585
bound_generic_params,
1584
1586
bounded_ty,
1585
1587
bounds,
1586
1588
span,
1587
- }) => hir::WherePredicate::BoundPredicate(hir::WhereBoundPredicate {
1588
- hir_id: self.next_id(),
1589
+ }) => hir::WherePredicateKind::BoundPredicate(hir::WhereBoundPredicate {
1589
1590
bound_generic_params: self
1590
1591
.lower_generic_params(bound_generic_params, hir::GenericParamSource::Binder),
1591
1592
bounded_ty: self
@@ -1597,26 +1598,31 @@ impl<'hir> LoweringContext<'_, 'hir> {
1597
1598
span: self.lower_span(*span),
1598
1599
origin: PredicateOrigin::WhereClause,
1599
1600
}),
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 {
1601
+ WherePredicateKind::RegionPredicate(WhereRegionPredicate {
1602
+ lifetime,
1603
+ bounds,
1604
+ span,
1605
+ }) => hir::WherePredicateKind::RegionPredicate(hir::WhereRegionPredicate {
1606
+ span: self.lower_span(*span),
1607
+ lifetime: self.lower_lifetime(lifetime),
1608
+ bounds: self.lower_param_bounds(
1609
+ bounds,
1610
+ ImplTraitContext::Disallowed(ImplTraitPosition::Bound),
1611
+ ),
1612
+ in_where_clause: true,
1613
+ }),
1614
+ WherePredicateKind::EqPredicate(WhereEqPredicate { lhs_ty, rhs_ty, span }) => {
1615
+ hir::WherePredicateKind::EqPredicate(hir::WhereEqPredicate {
1613
1616
lhs_ty: self
1614
1617
.lower_ty(lhs_ty, ImplTraitContext::Disallowed(ImplTraitPosition::Bound)),
1615
1618
rhs_ty: self
1616
1619
.lower_ty(rhs_ty, ImplTraitContext::Disallowed(ImplTraitPosition::Bound)),
1617
1620
span: self.lower_span(*span),
1618
1621
})
1619
1622
}
1620
- }
1623
+ };
1624
+ let kind = self.arena.alloc(kind);
1625
+ let span = self.lower_span(pred.span);
1626
+ hir::WherePredicate { hir_id, kind, span }
1621
1627
}
1622
1628
}
0 commit comments