@@ -340,13 +340,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
340340                ) ; 
341341                hir:: ItemKind :: Union ( ident,  generics,  vdata) 
342342            } 
343-             ItemKind :: Impl ( box Impl  { 
344-                 safety, 
345-                 polarity, 
346-                 defaultness, 
347-                 constness, 
343+             ItemKind :: Impl ( Impl  { 
348344                generics :  ast_generics, 
349-                 of_trait :  trait_ref , 
345+                 of_trait, 
350346                self_ty :  ty, 
351347                items :  impl_items, 
352348            } )  => { 
@@ -364,54 +360,30 @@ impl<'hir> LoweringContext<'_, 'hir> {
364360                // lifetime to be added, but rather a reference to a 
365361                // parent lifetime. 
366362                let  itctx = ImplTraitContext :: Universal ; 
367-                 let  ( generics,  ( trait_ref ,  lowered_ty) )  =
363+                 let  ( generics,  ( of_trait ,  lowered_ty) )  =
368364                    self . lower_generics ( ast_generics,  id,  itctx,  |this| { 
369-                         let  modifiers = TraitBoundModifiers  { 
370-                             constness :  BoundConstness :: Never , 
371-                             asyncness :  BoundAsyncness :: Normal , 
372-                             // we don't use this in bound lowering 
373-                             polarity :  BoundPolarity :: Positive , 
374-                         } ; 
375- 
376-                         let  trait_ref = trait_ref. as_ref ( ) . map ( |trait_ref| { 
377-                             this. lower_trait_ref ( 
378-                                 modifiers, 
379-                                 trait_ref, 
380-                                 ImplTraitContext :: Disallowed ( ImplTraitPosition :: Trait ) , 
381-                             ) 
382-                         } ) ; 
365+                         let  of_trait = of_trait
366+                             . as_deref ( ) 
367+                             . map ( |of_trait| this. lower_trait_impl_header ( of_trait) ) ; 
383368
384369                        let  lowered_ty = this. lower_ty ( 
385370                            ty, 
386371                            ImplTraitContext :: Disallowed ( ImplTraitPosition :: ImplSelf ) , 
387372                        ) ; 
388373
389-                         ( trait_ref ,  lowered_ty) 
374+                         ( of_trait ,  lowered_ty) 
390375                    } ) ; 
391376
392377                let  new_impl_items = self 
393378                    . arena 
394379                    . alloc_from_iter ( impl_items. iter ( ) . map ( |item| self . lower_impl_item_ref ( item) ) ) ; 
395380
396-                 // `defaultness.has_value()` is never called for an `impl`, always `true` in order 
397-                 // to not cause an assertion failure inside the `lower_defaultness` function. 
398-                 let  has_val = true ; 
399-                 let  ( defaultness,  defaultness_span)  = self . lower_defaultness ( * defaultness,  has_val) ; 
400-                 let  polarity = match  polarity { 
401-                     ImplPolarity :: Positive  => ImplPolarity :: Positive , 
402-                     ImplPolarity :: Negative ( s)  => ImplPolarity :: Negative ( self . lower_span ( * s) ) , 
403-                 } ; 
404-                 hir:: ItemKind :: Impl ( self . arena . alloc ( hir:: Impl  { 
405-                     constness :  self . lower_constness ( * constness) , 
406-                     safety :  self . lower_safety ( * safety,  hir:: Safety :: Safe ) , 
407-                     polarity, 
408-                     defaultness, 
409-                     defaultness_span, 
381+                 hir:: ItemKind :: Impl ( hir:: Impl  { 
410382                    generics, 
411-                     of_trait :  trait_ref , 
383+                     of_trait, 
412384                    self_ty :  lowered_ty, 
413385                    items :  new_impl_items, 
414-                 } ) ) 
386+                 } ) 
415387            } 
416388            ItemKind :: Trait ( box Trait  { 
417389                constness, 
@@ -982,6 +954,44 @@ impl<'hir> LoweringContext<'_, 'hir> {
982954        self . expr ( span,  hir:: ExprKind :: Err ( guar) ) 
983955    } 
984956
957+     fn  lower_trait_impl_header ( 
958+         & mut  self , 
959+         trait_impl_header :  & TraitImplHeader , 
960+     )  -> & ' hir  hir:: TraitImplHeader < ' hir >  { 
961+         let  TraitImplHeader  {  constness,  safety,  polarity,  defaultness,  ref  trait_ref }  =
962+             * trait_impl_header; 
963+         let  constness = self . lower_constness ( constness) ; 
964+         let  safety = self . lower_safety ( safety,  hir:: Safety :: Safe ) ; 
965+         let  polarity = match  polarity { 
966+             ImplPolarity :: Positive  => ImplPolarity :: Positive , 
967+             ImplPolarity :: Negative ( s)  => ImplPolarity :: Negative ( self . lower_span ( s) ) , 
968+         } ; 
969+         // `defaultness.has_value()` is never called for an `impl`, always `true` in order 
970+         // to not cause an assertion failure inside the `lower_defaultness` function. 
971+         let  has_val = true ; 
972+         let  ( defaultness,  defaultness_span)  = self . lower_defaultness ( defaultness,  has_val) ; 
973+         let  modifiers = TraitBoundModifiers  { 
974+             constness :  BoundConstness :: Never , 
975+             asyncness :  BoundAsyncness :: Normal , 
976+             // we don't use this in bound lowering 
977+             polarity :  BoundPolarity :: Positive , 
978+         } ; 
979+         let  trait_ref = self . lower_trait_ref ( 
980+             modifiers, 
981+             trait_ref, 
982+             ImplTraitContext :: Disallowed ( ImplTraitPosition :: Trait ) , 
983+         ) ; 
984+ 
985+         self . arena . alloc ( hir:: TraitImplHeader  { 
986+             constness, 
987+             safety, 
988+             polarity, 
989+             defaultness, 
990+             defaultness_span, 
991+             trait_ref, 
992+         } ) 
993+     } 
994+ 
985995    fn  lower_impl_item ( 
986996        & mut  self , 
987997        i :  & AssocItem , 
0 commit comments