mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-17 01:13:11 +00:00
Don't remap early-bound RPITIT regions that originate from impl
This commit is contained in:
parent
ab5a2bc731
commit
72fbb54c5d
@ -590,7 +590,13 @@ 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(_) | ty::ReEarlyBound(_)) = region.kind() else { return region; };
|
||||
match region.kind() {
|
||||
// Remap all free regions, which correspond to late-bound regions in the function.
|
||||
ty::ReFree(_) => {}
|
||||
// Remap early-bound regions as long as they don't come from the `impl` itself.
|
||||
ty::ReEarlyBound(ebr) if tcx.parent(ebr.def_id) != impl_m.container_id(tcx) => {}
|
||||
_ => return region,
|
||||
}
|
||||
let Some(ty::ReEarlyBound(e)) = map.get(®ion.into()).map(|r| r.expect_region().kind())
|
||||
else {
|
||||
tcx
|
||||
|
17
src/test/ui/async-await/in-trait/early-bound-1.rs
Normal file
17
src/test/ui/async-await/in-trait/early-bound-1.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// check-pass
|
||||
// edition:2021
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
pub trait Foo {
|
||||
async fn foo(&mut self);
|
||||
}
|
||||
|
||||
struct MyFoo<'a>(&'a mut ());
|
||||
|
||||
impl<'a> Foo for MyFoo<'a> {
|
||||
async fn foo(&mut self) {}
|
||||
}
|
||||
|
||||
fn main() {}
|
15
src/test/ui/async-await/in-trait/early-bound-2.rs
Normal file
15
src/test/ui/async-await/in-trait/early-bound-2.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// check-pass
|
||||
// edition:2021
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
pub trait Foo {
|
||||
async fn foo(&mut self);
|
||||
}
|
||||
|
||||
impl<T: Foo> Foo for &mut T {
|
||||
async fn foo(&mut self) {}
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user