Skip to content

Commit 112fd02

Browse files
authored
Rollup merge of #103608 - compiler-errors:rpitit-early-lt, r=cjgillot
Remap early bound lifetimes in return-position `impl Trait` in traits too Fixes part of #103457 r? ``@cjgillot,`` though feel free to reassign, just thought you'd have sufficient context to review.
2 parents 6e1613a + b1cc95d commit 112fd02

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

compiler/rustc_hir_analysis/src/check/compare_method.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ pub fn collect_trait_impl_trait_tys<'tcx>(
597597
let num_trait_substs = trait_to_impl_substs.len();
598598
let num_impl_substs = tcx.generics_of(impl_m.container_id(tcx)).params.len();
599599
let ty = tcx.fold_regions(ty, |region, _| {
600-
let ty::ReFree(_) = region.kind() else { return region; };
600+
let (ty::ReFree(_) | ty::ReEarlyBound(_)) = region.kind() else { return region; };
601601
let Some(ty::ReEarlyBound(e)) = map.get(&region.into()).map(|r| r.expect_region().kind())
602602
else {
603603
tcx
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// check-pass
2+
// edition:2021
3+
4+
#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)]
5+
#![allow(incomplete_features)]
6+
7+
pub trait Foo {
8+
async fn bar<'a: 'a>(&'a mut self);
9+
}
10+
11+
impl Foo for () {
12+
async fn bar<'a: 'a>(&'a mut self) {}
13+
}
14+
15+
pub trait Foo2 {
16+
fn bar<'a: 'a>(&'a mut self) -> impl Sized + 'a;
17+
}
18+
19+
impl Foo2 for () {
20+
fn bar<'a: 'a>(&'a mut self) -> impl Sized + 'a {}
21+
}
22+
23+
fn main() {}

0 commit comments

Comments
 (0)