diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-10-28 07:06:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-28 07:06:46 +0200 |
| commit | 112fd022cd42698f644333206ef5335069b1ea13 (patch) | |
| tree | 851a4a9ce8938b9647b90a0e8685be3415fcf79b | |
| parent | 6e1613a0c534f385e8df4b9a5cffdec29be22972 (diff) | |
| parent | b1cc95da2338af399e65c7186540e2f412c8fbe0 (diff) | |
| download | rust-112fd022cd42698f644333206ef5335069b1ea13.tar.gz rust-112fd022cd42698f644333206ef5335069b1ea13.zip | |
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.
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/compare_method.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/in-trait/early.rs | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/compare_method.rs b/compiler/rustc_hir_analysis/src/check/compare_method.rs index e72f18012ab..32f66b06f83 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_method.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_method.rs @@ -597,7 +597,7 @@ pub fn collect_trait_impl_trait_tys<'tcx>( let num_trait_substs = trait_to_impl_substs.len(); let num_impl_substs = tcx.generics_of(impl_m.container_id(tcx)).params.len(); let ty = tcx.fold_regions(ty, |region, _| { - let ty::ReFree(_) = region.kind() else { return region; }; + let (ty::ReFree(_) | ty::ReEarlyBound(_)) = region.kind() else { return region; }; let Some(ty::ReEarlyBound(e)) = map.get(®ion.into()).map(|r| r.expect_region().kind()) else { tcx diff --git a/src/test/ui/impl-trait/in-trait/early.rs b/src/test/ui/impl-trait/in-trait/early.rs new file mode 100644 index 00000000000..9c1c2b50339 --- /dev/null +++ b/src/test/ui/impl-trait/in-trait/early.rs @@ -0,0 +1,23 @@ +// check-pass +// edition:2021 + +#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] +#![allow(incomplete_features)] + +pub trait Foo { + async fn bar<'a: 'a>(&'a mut self); +} + +impl Foo for () { + async fn bar<'a: 'a>(&'a mut self) {} +} + +pub trait Foo2 { + fn bar<'a: 'a>(&'a mut self) -> impl Sized + 'a; +} + +impl Foo2 for () { + fn bar<'a: 'a>(&'a mut self) -> impl Sized + 'a {} +} + +fn main() {} |
