diff options
| author | bors <bors@rust-lang.org> | 2025-08-11 09:03:18 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-08-11 09:03:18 +0000 |
| commit | 577166503aee7290e09374da21f4045c455acfd5 (patch) | |
| tree | d59f60d60e5a9e39f62f2f6d2ff8eac97d9d996d /compiler/rustc_trait_selection/src/traits/select/mod.rs | |
| parent | a6620a45bd29575cce67b6a0ab2956aef105e324 (diff) | |
| parent | 3ce0ee2555bb34c9dc51f0b4afc6a9dba61b26df (diff) | |
| download | rust-577166503aee7290e09374da21f4045c455acfd5.tar.gz rust-577166503aee7290e09374da21f4045c455acfd5.zip | |
Auto merge of #145240 - Zalathar:rollup-7r97lia, r=Zalathar
Rollup of 5 pull requests Successful merges: - rust-lang/rust#135331 (Reject relaxed bounds inside associated type bounds (ATB)) - rust-lang/rust#144156 (Check coroutine upvars in dtorck constraint) - rust-lang/rust#145091 (`NllRegionVariableOrigin` remove `from_forall`) - rust-lang/rust#145194 (Ignore coroutine witness type region args in auto trait confirmation) - rust-lang/rust#145225 (Fix macro infinite recursion test to not trigger warning about semicolon in expr) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits/select/mod.rs')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/select/mod.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 7ea1548f8f2..468c42abf48 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -2333,10 +2333,23 @@ impl<'tcx> SelectionContext<'_, 'tcx> { ty::Coroutine(def_id, args) => { let ty = self.infcx.shallow_resolve(args.as_coroutine().tupled_upvars_ty()); + let tcx = self.tcx(); let witness = Ty::new_coroutine_witness( - self.tcx(), + tcx, def_id, - self.tcx().mk_args(args.as_coroutine().parent_args()), + ty::GenericArgs::for_item(tcx, def_id, |def, _| match def.kind { + // HACK: Coroutine witnesse types are lifetime erased, so they + // never reference any lifetime args from the coroutine. We erase + // the regions here since we may get into situations where a + // coroutine is recursively contained within itself, leading to + // witness types that differ by region args. This means that + // cycle detection in fulfillment will not kick in, which leads + // to unnecessary overflows in async code. See the issue: + // <https://github.com/rust-lang/rust/issues/145151>. + ty::GenericParamDefKind::Lifetime => tcx.lifetimes.re_erased.into(), + ty::GenericParamDefKind::Type { .. } + | ty::GenericParamDefKind::Const { .. } => args[def.index as usize], + }), ); ty::Binder::dummy(AutoImplConstituents { types: [ty].into_iter().chain(iter::once(witness)).collect(), |
