diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-09-24 23:33:29 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-24 23:33:29 +0200 |
| commit | 57ee169ff281fcdfd02384ef0760f4ce8162478f (patch) | |
| tree | d76007a9ba4ef7f42b9cc52c18ba3719cce1598a | |
| parent | d10d6bfb02de77c472de7906e58b77e94d35c058 (diff) | |
| parent | 2886ca496a8adff7424da8b19eeaffa9d392210c (diff) | |
| download | rust-57ee169ff281fcdfd02384ef0760f4ce8162478f.tar.gz rust-57ee169ff281fcdfd02384ef0760f4ce8162478f.zip | |
Rollup merge of #146971 - lcnr:fix-writeback, r=BoxyUwU
fix ICE in writeback due to bound regions fixes rust-lang/rust#117808 r? `@BoxyUwU`
| -rw-r--r-- | compiler/rustc_hir_typeck/src/writeback.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs | 6 | ||||
| -rw-r--r-- | tests/crashes/117808.rs | 27 | ||||
| -rw-r--r-- | tests/ui/traits/next-solver/writeback-predicate-bound-region.rs | 14 |
4 files changed, 21 insertions, 32 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/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs index 6ce68507d65..a96cb738b81 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs @@ -100,9 +100,9 @@ where } else if let Err(guar) = infcx.tcx.check_potentially_region_dependent_goals(root_def_id) { Err(guar) } else { - Err(infcx - .dcx() - .delayed_bug(format!("errors selecting obligation during MIR typeck: {errors:?}"))) + Err(infcx.dcx().delayed_bug(format!( + "errors selecting obligation during MIR typeck: {name} {root_def_id:?} {errors:?}" + ))) } })?; 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 {}) +} |
