@@ -514,38 +514,11 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
514
514
// These sorts of items have no lifetime parameters at all.
515
515
intravisit:: walk_item ( self , item) ;
516
516
}
517
- hir:: ItemKind :: OpaqueTy ( hir:: OpaqueTy {
518
- origin : hir:: OpaqueTyOrigin :: TyAlias { .. } ,
519
- ..
520
- } ) => {
521
- // Opaque types are visited when we visit the
522
- // `TyKind::OpaqueDef`, so that they have the lifetimes from
523
- // their parent opaque_ty in scope.
524
- //
525
- // The core idea here is that since OpaqueTys are generated with the impl Trait as
526
- // their owner, we can keep going until we find the Item that owns that. We then
527
- // conservatively add all resolved lifetimes. Otherwise we run into problems in
528
- // cases like `type Foo<'a> = impl Bar<As = impl Baz + 'a>`.
529
- let parent_item = self . tcx . hir ( ) . get_parent_item ( item. hir_id ( ) ) ;
530
- let resolved_lifetimes: & ResolveBoundVars =
531
- self . tcx . resolve_bound_vars ( parent_item) ;
532
- // We need to add *all* deps, since opaque tys may want them from *us*
533
- for ( & owner, defs) in resolved_lifetimes. defs . iter ( ) {
534
- defs. iter ( ) . for_each ( |( & local_id, region) | {
535
- self . map . defs . insert ( hir:: HirId { owner, local_id } , * region) ;
536
- } ) ;
537
- }
538
- for ( & owner, late_bound_vars) in resolved_lifetimes. late_bound_vars . iter ( ) {
539
- late_bound_vars. iter ( ) . for_each ( |( & local_id, late_bound_vars) | {
540
- self . record_late_bound_vars (
541
- hir:: HirId { owner, local_id } ,
542
- late_bound_vars. clone ( ) ,
543
- ) ;
544
- } ) ;
545
- }
546
- }
547
517
hir:: ItemKind :: OpaqueTy ( & hir:: OpaqueTy {
548
- origin : hir:: OpaqueTyOrigin :: FnReturn ( parent) | hir:: OpaqueTyOrigin :: AsyncFn ( parent) ,
518
+ origin :
519
+ hir:: OpaqueTyOrigin :: FnReturn ( parent)
520
+ | hir:: OpaqueTyOrigin :: AsyncFn ( parent)
521
+ | hir:: OpaqueTyOrigin :: TyAlias { parent, .. } ,
549
522
generics,
550
523
..
551
524
} ) => {
@@ -683,26 +656,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
683
656
// the opaque_ty generics
684
657
let opaque_ty = self . tcx . hir ( ) . item ( item_id) ;
685
658
match & opaque_ty. kind {
686
- hir:: ItemKind :: OpaqueTy ( hir:: OpaqueTy {
687
- origin : hir:: OpaqueTyOrigin :: TyAlias { .. } ,
688
- ..
689
- } ) => {
690
- intravisit:: walk_ty ( self , ty) ;
691
-
692
- // Elided lifetimes and late-bound lifetimes (from the parent)
693
- // are not allowed in non-return position impl Trait
694
- let scope = Scope :: LateBoundary {
695
- s : & Scope :: TraitRefBoundary { s : self . scope } ,
696
- what : "type alias impl trait" ,
697
- } ;
698
- self . with ( scope, |this| intravisit:: walk_item ( this, opaque_ty) ) ;
699
-
700
- return ;
701
- }
702
- hir:: ItemKind :: OpaqueTy ( hir:: OpaqueTy {
703
- origin : hir:: OpaqueTyOrigin :: FnReturn ( ..) | hir:: OpaqueTyOrigin :: AsyncFn ( ..) ,
704
- ..
705
- } ) => { }
659
+ hir:: ItemKind :: OpaqueTy ( hir:: OpaqueTy { origin : _, .. } ) => { }
706
660
i => bug ! ( "`impl Trait` pointed to non-opaque type?? {:#?}" , i) ,
707
661
} ;
708
662
0 commit comments