@@ -1400,7 +1400,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14001400 // keep track of the Span info. Now, `<dyn HirTyLowerer>::add_implicit_sized_bound`
14011401 // checks both param bounds and where clauses for `?Sized`.
14021402 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 {
14041404 continue ;
14051405 } ;
14061406 let compute_is_param = || {
@@ -1538,8 +1538,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
15381538 } ) ;
15391539 let span = self . lower_span ( span) ;
15401540
1541- match kind {
1542- GenericParamKind :: Const { .. } => None ,
1541+ let kind = match kind {
1542+ GenericParamKind :: Const { .. } => return None ,
15431543 GenericParamKind :: Type { .. } => {
15441544 let def_id = self . local_def_id ( id) . to_def_id ( ) ;
15451545 let hir_id = self . next_id ( ) ;
@@ -1554,38 +1554,39 @@ impl<'hir> LoweringContext<'_, 'hir> {
15541554 let ty_id = self . next_id ( ) ;
15551555 let bounded_ty =
15561556 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 {
15591558 bounded_ty : self . arena . alloc ( bounded_ty) ,
15601559 bounds,
15611560 span,
15621561 bound_generic_params : & [ ] ,
15631562 origin,
1564- } ) )
1563+ } )
15651564 }
15661565 GenericParamKind :: Lifetime => {
15671566 let ident = self . lower_ident ( ident) ;
15681567 let lt_id = self . next_node_id ( ) ;
15691568 let lifetime = self . new_named_lifetime ( id, lt_id, ident) ;
1570- Some ( hir:: WherePredicate :: RegionPredicate ( hir:: WhereRegionPredicate {
1569+ hir:: WherePredicateKind :: RegionPredicate ( hir:: WhereRegionPredicate {
15711570 lifetime,
15721571 span,
15731572 bounds,
15741573 in_where_clause : false ,
1575- } ) )
1574+ } )
15761575 }
1577- }
1576+ } ;
1577+ Some ( hir:: WherePredicate { hir_id : self . next_id ( ) , kind : self . arena . alloc ( kind) , span } )
15781578 }
15791579
15801580 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 {
15831585 bound_generic_params,
15841586 bounded_ty,
15851587 bounds,
15861588 span,
1587- } ) => hir:: WherePredicate :: BoundPredicate ( hir:: WhereBoundPredicate {
1588- hir_id : self . next_id ( ) ,
1589+ } ) => hir:: WherePredicateKind :: BoundPredicate ( hir:: WhereBoundPredicate {
15891590 bound_generic_params : self
15901591 . lower_generic_params ( bound_generic_params, hir:: GenericParamSource :: Binder ) ,
15911592 bounded_ty : self
@@ -1597,26 +1598,31 @@ impl<'hir> LoweringContext<'_, 'hir> {
15971598 span : self . lower_span ( * span) ,
15981599 origin : PredicateOrigin :: WhereClause ,
15991600 } ) ,
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 {
16131616 lhs_ty : self
16141617 . lower_ty ( lhs_ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ) ,
16151618 rhs_ty : self
16161619 . lower_ty ( rhs_ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ) ,
16171620 span : self . lower_span ( * span) ,
16181621 } )
16191622 }
1620- }
1623+ } ;
1624+ let kind = self . arena . alloc ( kind) ;
1625+ let span = self . lower_span ( pred. span ) ;
1626+ hir:: WherePredicate { hir_id, kind, span }
16211627 }
16221628}
0 commit comments