@@ -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,38 @@ 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+ let kind = match & pred. kind {
1583+ WherePredicateKind :: BoundPredicate ( WhereBoundPredicate {
15831584 bound_generic_params,
15841585 bounded_ty,
15851586 bounds,
15861587 span,
1587- } ) => hir:: WherePredicate :: BoundPredicate ( hir:: WhereBoundPredicate {
1588- hir_id : self . next_id ( ) ,
1588+ } ) => hir:: WherePredicateKind :: BoundPredicate ( hir:: WhereBoundPredicate {
15891589 bound_generic_params : self
15901590 . lower_generic_params ( bound_generic_params, hir:: GenericParamSource :: Binder ) ,
15911591 bounded_ty : self
@@ -1597,26 +1597,31 @@ impl<'hir> LoweringContext<'_, 'hir> {
15971597 span : self . lower_span ( * span) ,
15981598 origin : PredicateOrigin :: WhereClause ,
15991599 } ) ,
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 {
16131615 lhs_ty : self
16141616 . lower_ty ( lhs_ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ) ,
16151617 rhs_ty : self
16161618 . lower_ty ( rhs_ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ) ,
16171619 span : self . lower_span ( * span) ,
16181620 } )
16191621 }
1620- }
1622+ } ;
1623+ let kind = self . arena . alloc ( kind) ;
1624+ let span = self . lower_span ( pred. span ) ;
1625+ hir:: WherePredicate { hir_id, kind, span }
16211626 }
16221627}
0 commit comments