@@ -559,13 +559,15 @@ pub struct NamedLifetimeStore {
559559 lifetimes_in_where_clause : FxIndexSet < Name > ,
560560 lifetimes_constraint_by_input : FxIndexSet < Name > ,
561561 lifetimes_in_output : FxIndexSet < Name > ,
562+ opaque_captured_lifetimes : FxIndexSet < Name > ,
562563}
563564
564565#[ derive( Debug ) ]
565566enum LifetimeBoundScope {
566567 Argument ,
567568 Return ,
568569 WhereClause ,
570+ ImplTrait ( bool ) ,
569571}
570572
571573impl NamedLifetimeStore {
@@ -574,13 +576,23 @@ impl NamedLifetimeStore {
574576 pub ( crate ) fn push_named_lifetime ( & mut self , lifetime : Name ) {
575577 match self . lifetime_bound_scope {
576578 Some ( LifetimeBoundScope :: Argument ) => {
577- self . lifetimes_constraint_by_input . insert ( lifetime)
579+ self . lifetimes_constraint_by_input . insert ( lifetime) ;
580+ }
581+ Some ( LifetimeBoundScope :: Return ) => {
582+ self . lifetimes_in_output . insert ( lifetime) ;
578583 }
579- Some ( LifetimeBoundScope :: Return ) => self . lifetimes_in_output . insert ( lifetime) ,
580584 Some ( LifetimeBoundScope :: WhereClause ) => {
581- self . lifetimes_in_where_clause . insert ( lifetime)
585+ self . lifetimes_in_where_clause . insert ( lifetime) ;
586+ }
587+ Some ( LifetimeBoundScope :: ImplTrait ( is_argument_scope) ) => {
588+ if is_argument_scope {
589+ self . lifetimes_in_where_clause . insert ( lifetime) ;
590+ } else {
591+ self . opaque_captured_lifetimes . insert ( lifetime. clone ( ) ) ;
592+ self . lifetimes_in_output . insert ( lifetime) ;
593+ }
582594 }
583- _ => false ,
595+ _ => ( ) ,
584596 } ;
585597 }
586598}
@@ -751,8 +763,16 @@ impl<'db> ExprCollector<'db> {
751763 TypeRef :: Error
752764 } else {
753765 return self . with_outer_impl_trait_scope ( true , |this| {
754- let type_bounds =
755- this. type_bounds_from_ast ( inner. type_bound_list ( ) , impl_trait_lower_fn) ;
766+ let is_argument_lt_bound_scope = this. is_argument_lt_bound_scope ( ) ;
767+ let type_bounds = this. with_lifetime_bound_scope (
768+ LifetimeBoundScope :: ImplTrait ( is_argument_lt_bound_scope) ,
769+ |this| {
770+ this. type_bounds_from_ast (
771+ inner. type_bound_list ( ) ,
772+ impl_trait_lower_fn,
773+ )
774+ } ,
775+ ) ;
756776 impl_trait_lower_fn ( this, AstPtr :: new ( & node) , type_bounds)
757777 } ) ;
758778 }
0 commit comments