]> git.lizzy.rs Git - rust.git/commitdiff
Remap early bound lifetimes too
authorMichael Goulet <michael@errs.io>
Mon, 24 Oct 2022 03:33:42 +0000 (03:33 +0000)
committerMichael Goulet <michael@errs.io>
Thu, 27 Oct 2022 00:28:54 +0000 (00:28 +0000)
compiler/rustc_hir_analysis/src/check/compare_method.rs
src/test/ui/impl-trait/in-trait/early.rs [new file with mode: 0644]

index e72f18012ab338fce240ac21202e0439e279097a..32f66b06f835859cd34c5c934ae2a9f0c71ad702 100644 (file)
@@ -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(&region.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 (file)
index 0000000..9c1c2b5
--- /dev/null
@@ -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() {}