@@ -616,7 +616,7 @@ impl<'a, 'b, 'db> PathLoweringContext<'a, 'b, 'db> {
616
616
explicit_self_ty : Option < Ty < ' db > > ,
617
617
lowering_assoc_type_generics : bool ,
618
618
) -> crate :: next_solver:: GenericArgs < ' db > {
619
- let mut lifetime_elision = self . ctx . lifetime_elision . clone ( ) ;
619
+ let old_lifetime_elision = self . ctx . lifetime_elision . clone ( ) ;
620
620
621
621
if let Some ( args) = self . current_or_prev_segment . args_and_bindings
622
622
&& args. parenthesized != GenericArgsParentheses :: No
@@ -646,19 +646,21 @@ impl<'a, 'b, 'db> PathLoweringContext<'a, 'b, 'db> {
646
646
}
647
647
648
648
// `Fn()`-style generics are treated like functions for the purpose of lifetime elision.
649
- lifetime_elision =
649
+ self . ctx . lifetime_elision =
650
650
LifetimeElisionKind :: AnonymousCreateParameter { report_in_path : false } ;
651
651
}
652
652
653
- self . substs_from_args_and_bindings (
653
+ let result = self . substs_from_args_and_bindings (
654
654
self . current_or_prev_segment . args_and_bindings ,
655
655
def,
656
656
infer_args,
657
657
explicit_self_ty,
658
658
PathGenericsSource :: Segment ( self . current_segment_u32 ( ) ) ,
659
659
lowering_assoc_type_generics,
660
- lifetime_elision,
661
- )
660
+ self . ctx . lifetime_elision . clone ( ) ,
661
+ ) ;
662
+ self . ctx . lifetime_elision = old_lifetime_elision;
663
+ result
662
664
}
663
665
664
666
pub ( super ) fn substs_from_args_and_bindings (
@@ -915,22 +917,36 @@ impl<'a, 'b, 'db> PathLoweringContext<'a, 'b, 'db> {
915
917
binding. type_ref . as_ref ( ) . map_or ( 0 , |_| 1 ) + binding. bounds . len ( ) ,
916
918
) ;
917
919
if let Some ( type_ref) = binding. type_ref {
918
- match ( & self . ctx . store [ type_ref] , self . ctx . impl_trait_mode . mode ) {
919
- ( TypeRef :: ImplTrait ( _) , ImplTraitLoweringMode :: Disallowed ) => ( ) ,
920
- ( _, ImplTraitLoweringMode :: Disallowed | ImplTraitLoweringMode :: Opaque ) => {
921
- let ty = self . ctx . lower_ty ( type_ref) ;
922
- let pred = Clause ( Predicate :: new (
923
- interner,
924
- Binder :: dummy ( rustc_type_ir:: PredicateKind :: Clause (
925
- rustc_type_ir:: ClauseKind :: Projection ( ProjectionPredicate {
926
- projection_term,
927
- term : ty. into ( ) ,
928
- } ) ,
929
- ) ) ,
930
- ) ) ;
931
- predicates. push ( pred) ;
920
+ let lifetime_elision =
921
+ if args_and_bindings. parenthesized == GenericArgsParentheses :: ParenSugar {
922
+ // `Fn()`-style generics are elided like functions. This is `Output` (we lower to it in hir-def).
923
+ LifetimeElisionKind :: for_fn_ret ( self . ctx . interner )
924
+ } else {
925
+ self . ctx . lifetime_elision . clone ( )
926
+ } ;
927
+ self . with_lifetime_elision ( lifetime_elision, |this| {
928
+ match ( & this. ctx . store [ type_ref] , this. ctx . impl_trait_mode . mode ) {
929
+ ( TypeRef :: ImplTrait ( _) , ImplTraitLoweringMode :: Disallowed ) => ( ) ,
930
+ (
931
+ _,
932
+ ImplTraitLoweringMode :: Disallowed | ImplTraitLoweringMode :: Opaque ,
933
+ ) => {
934
+ let ty = this. ctx . lower_ty ( type_ref) ;
935
+ let pred = Clause ( Predicate :: new (
936
+ interner,
937
+ Binder :: dummy ( rustc_type_ir:: PredicateKind :: Clause (
938
+ rustc_type_ir:: ClauseKind :: Projection (
939
+ ProjectionPredicate {
940
+ projection_term,
941
+ term : ty. into ( ) ,
942
+ } ,
943
+ ) ,
944
+ ) ) ,
945
+ ) ) ;
946
+ predicates. push ( pred) ;
947
+ }
932
948
}
933
- }
949
+ } )
934
950
}
935
951
for bound in binding. bounds . iter ( ) {
936
952
predicates. extend ( self . ctx . lower_type_bound (
0 commit comments