@@ -341,13 +341,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
341
341
) ;
342
342
hir:: ItemKind :: Union ( ident, generics, vdata)
343
343
}
344
- ItemKind :: Impl ( box Impl {
345
- safety,
346
- polarity,
347
- defaultness,
348
- constness,
344
+ ItemKind :: Impl ( Impl {
349
345
generics : ast_generics,
350
- of_trait : trait_ref ,
346
+ of_trait,
351
347
self_ty : ty,
352
348
items : impl_items,
353
349
} ) => {
@@ -365,54 +361,69 @@ impl<'hir> LoweringContext<'_, 'hir> {
365
361
// lifetime to be added, but rather a reference to a
366
362
// parent lifetime.
367
363
let itctx = ImplTraitContext :: Universal ;
368
- let ( generics, ( trait_ref , lowered_ty) ) =
364
+ let ( generics, ( of_trait , lowered_ty) ) =
369
365
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 (
379
394
modifiers,
380
395
trait_ref,
381
396
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
+ } )
383
407
} ) ;
384
408
385
409
let lowered_ty = this. lower_ty (
386
410
ty,
387
411
ImplTraitContext :: Disallowed ( ImplTraitPosition :: ImplSelf ) ,
388
412
) ;
389
413
390
- ( trait_ref , lowered_ty)
414
+ ( of_trait , lowered_ty)
391
415
} ) ;
392
416
393
417
let new_impl_items = self
394
418
. arena
395
419
. alloc_from_iter ( impl_items. iter ( ) . map ( |item| self . lower_impl_item_ref ( item) ) ) ;
396
420
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 {
411
422
generics,
412
- of_trait : trait_ref ,
423
+ of_trait,
413
424
self_ty : lowered_ty,
414
425
items : new_impl_items,
415
- } ) )
426
+ } )
416
427
}
417
428
ItemKind :: Trait ( box Trait {
418
429
constness,
0 commit comments