@@ -341,13 +341,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
341341 ) ;
342342 hir:: ItemKind :: Union ( ident, generics, vdata)
343343 }
344- ItemKind :: Impl ( box Impl {
345- safety,
346- polarity,
347- defaultness,
348- constness,
344+ ItemKind :: Impl ( Impl {
349345 generics : ast_generics,
350- of_trait : trait_ref ,
346+ of_trait,
351347 self_ty : ty,
352348 items : impl_items,
353349 } ) => {
@@ -365,54 +361,69 @@ impl<'hir> LoweringContext<'_, 'hir> {
365361 // lifetime to be added, but rather a reference to a
366362 // parent lifetime.
367363 let itctx = ImplTraitContext :: Universal ;
368- let ( generics, ( trait_ref , lowered_ty) ) =
364+ let ( generics, ( of_trait , lowered_ty) ) =
369365 self . lower_generics ( ast_generics, id, itctx, |this| {
370- let modifiers = TraitBoundModifiers {
371- constness : BoundConstness :: Never ,
372- asyncness : BoundAsyncness :: Normal ,
373- // we don't use this in bound lowering
374- polarity : BoundPolarity :: Positive ,
375- } ;
376-
377- let trait_ref = trait_ref. as_ref ( ) . map ( |trait_ref| {
378- this. lower_trait_ref (
366+ let of_trait = of_trait. as_deref ( ) . map ( |of_trait| {
367+ let ImplOfTrait {
368+ constness,
369+ safety,
370+ polarity,
371+ defaultness,
372+ ref trait_ref,
373+ } = * of_trait;
374+ let constness = this. lower_constness ( constness) ;
375+ let safety = this. lower_safety ( safety, hir:: Safety :: Safe ) ;
376+ let polarity = match polarity {
377+ ImplPolarity :: Positive => ImplPolarity :: Positive ,
378+ ImplPolarity :: Negative ( s) => {
379+ ImplPolarity :: Negative ( this. lower_span ( s) )
380+ }
381+ } ;
382+ // `defaultness.has_value()` is never called for an `impl`, always `true` in order
383+ // to not cause an assertion failure inside the `lower_defaultness` function.
384+ let has_val = true ;
385+ let ( defaultness, defaultness_span) =
386+ this. lower_defaultness ( defaultness, has_val) ;
387+ let modifiers = TraitBoundModifiers {
388+ constness : BoundConstness :: Never ,
389+ asyncness : BoundAsyncness :: Normal ,
390+ // we don't use this in bound lowering
391+ polarity : BoundPolarity :: Positive ,
392+ } ;
393+ let trait_ref = this. lower_trait_ref (
379394 modifiers,
380395 trait_ref,
381396 ImplTraitContext :: Disallowed ( ImplTraitPosition :: Trait ) ,
382- )
397+ ) ;
398+
399+ & * this. arena . alloc ( hir:: ImplOfTrait {
400+ constness,
401+ safety,
402+ polarity,
403+ defaultness,
404+ defaultness_span,
405+ trait_ref,
406+ } )
383407 } ) ;
384408
385409 let lowered_ty = this. lower_ty (
386410 ty,
387411 ImplTraitContext :: Disallowed ( ImplTraitPosition :: ImplSelf ) ,
388412 ) ;
389413
390- ( trait_ref , lowered_ty)
414+ ( of_trait , lowered_ty)
391415 } ) ;
392416
393417 let new_impl_items = self
394418 . arena
395419 . alloc_from_iter ( impl_items. iter ( ) . map ( |item| self . lower_impl_item_ref ( item) ) ) ;
396420
397- // `defaultness.has_value()` is never called for an `impl`, always `true` in order
398- // to not cause an assertion failure inside the `lower_defaultness` function.
399- let has_val = true ;
400- let ( defaultness, defaultness_span) = self . lower_defaultness ( * defaultness, has_val) ;
401- let polarity = match polarity {
402- ImplPolarity :: Positive => ImplPolarity :: Positive ,
403- ImplPolarity :: Negative ( s) => ImplPolarity :: Negative ( self . lower_span ( * s) ) ,
404- } ;
405- hir:: ItemKind :: Impl ( self . arena . alloc ( hir:: Impl {
406- constness : self . lower_constness ( * constness) ,
407- safety : self . lower_safety ( * safety, hir:: Safety :: Safe ) ,
408- polarity,
409- defaultness,
410- defaultness_span,
421+ hir:: ItemKind :: Impl ( hir:: Impl {
411422 generics,
412- of_trait : trait_ref ,
423+ of_trait,
413424 self_ty : lowered_ty,
414425 items : new_impl_items,
415- } ) )
426+ } )
416427 }
417428 ItemKind :: Trait ( box Trait {
418429 constness,
0 commit comments