about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_hir_typeck/src/writeback.rs6
-rw-r--r--tests/crashes/117808.rs27
-rw-r--r--tests/ui/traits/next-solver/writeback-predicate-bound-region.rs14
3 files changed, 18 insertions, 29 deletions
diff --git a/compiler/rustc_hir_typeck/src/writeback.rs b/compiler/rustc_hir_typeck/src/writeback.rs
index 6192420898f..d01eeb9a4b6 100644
--- a/compiler/rustc_hir_typeck/src/writeback.rs
+++ b/compiler/rustc_hir_typeck/src/writeback.rs
@@ -1003,8 +1003,10 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx> {
     }
 
     fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
-        debug_assert!(!r.is_bound(), "Should not be resolving bound region.");
-        self.fcx.tcx.lifetimes.re_erased
+        match r.kind() {
+            ty::ReBound(..) => r,
+            _ => self.fcx.tcx.lifetimes.re_erased,
+        }
     }
 
     fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
diff --git a/tests/crashes/117808.rs b/tests/crashes/117808.rs
deleted file mode 100644
index 2c727986dd0..00000000000
--- a/tests/crashes/117808.rs
+++ /dev/null
@@ -1,27 +0,0 @@
-//@ known-bug: #117808
-//@ edition:2021
-//@ needs-rustc-debug-assertions
-
-use std::future::Future;
-
-fn hrc<R, F: for<'a> AsyncClosure<'a, (), R>>(f: F) -> F {
-    f
-}
-
-fn main() {
-    hrc(|x| async {});
-}
-
-trait AsyncClosure<'a, I, R>
-where
-    I: 'a,
-{
-}
-
-impl<'a, I, R, Fut, F> AsyncClosure<'a, I, R> for F
-where
-    I: 'a,
-    F: Fn(&'a I) -> Fut,
-    Fut: Future<Output = R> + Send + 'a,
-{
-}
diff --git a/tests/ui/traits/next-solver/writeback-predicate-bound-region.rs b/tests/ui/traits/next-solver/writeback-predicate-bound-region.rs
new file mode 100644
index 00000000000..a7ed5dbcf08
--- /dev/null
+++ b/tests/ui/traits/next-solver/writeback-predicate-bound-region.rs
@@ -0,0 +1,14 @@
+//@ edition: 2024
+//@ check-pass
+//@ compile-flags: -Znext-solver
+
+// This previously ICE'd during writeback when resolving
+// the stalled coroutine predicate due to its bound lifetime.
+
+trait Trait<'a> {}
+impl<'a, T: Send> Trait<'a> for T {}
+
+fn is_trait<T: for<'a> Trait<'a>>(_: T) {}
+fn main() {
+    is_trait(async {})
+}