File tree 3 files changed +39
-1
lines changed
compiler/rustc_hir_analysis/src/check
src/test/ui/async-await/in-trait
3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -590,7 +590,13 @@ pub fn collect_trait_impl_trait_tys<'tcx>(
590
590
let num_trait_substs = trait_to_impl_substs. len ( ) ;
591
591
let num_impl_substs = tcx. generics_of ( impl_m. container_id ( tcx) ) . params . len ( ) ;
592
592
let ty = tcx. fold_regions ( ty, |region, _| {
593
- let ( ty:: ReFree ( _) | ty:: ReEarlyBound ( _) ) = region. kind ( ) else { return region; } ;
593
+ match region. kind ( ) {
594
+ // Remap all free regions, which correspond to late-bound regions in the function.
595
+ ty:: ReFree ( _) => { }
596
+ // Remap early-bound regions as long as they don't come from the `impl` itself.
597
+ ty:: ReEarlyBound ( ebr) if tcx. parent ( ebr. def_id ) != impl_m. container_id ( tcx) => { }
598
+ _ => return region,
599
+ }
594
600
let Some ( ty:: ReEarlyBound ( e) ) = map. get ( & region. into ( ) ) . map ( |r| r. expect_region ( ) . kind ( ) )
595
601
else {
596
602
tcx
Original file line number Diff line number Diff line change
1
+ // check-pass
2
+ // edition:2021
3
+
4
+ #![ feature( async_fn_in_trait) ]
5
+ #![ allow( incomplete_features) ]
6
+
7
+ pub trait Foo {
8
+ async fn foo ( & mut self ) ;
9
+ }
10
+
11
+ struct MyFoo < ' a > ( & ' a mut ( ) ) ;
12
+
13
+ impl < ' a > Foo for MyFoo < ' a > {
14
+ async fn foo ( & mut self ) { }
15
+ }
16
+
17
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ // check-pass
2
+ // edition:2021
3
+
4
+ #![ feature( async_fn_in_trait) ]
5
+ #![ allow( incomplete_features) ]
6
+
7
+ pub trait Foo {
8
+ async fn foo ( & mut self ) ;
9
+ }
10
+
11
+ impl < T : Foo > Foo for & mut T {
12
+ async fn foo ( & mut self ) { }
13
+ }
14
+
15
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments