Change:
<!-- Thank you for filing a bug report! Please provide a short summary of the bug, along with any information you feel relevant to replicating the bug. --I tried this code: This is modification of with the difference being ` Rust OOM'd here after eating at least 20 gb of memory :sweat_smile: I expected to see this happen: explanation NO OOM, maybe an error Instead, this happened: explanation OOM <!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --:
WG-prioritization assigning priority (). label -I-prioritize +P-medium

Discussion:
} pub fn borrow_nested_obligations(&self) -> &[N] { <del> match &self { ImplSource::UserDefined(i) => &i.nested[..], ImplSource::Param(n, _) => &n, </del> <ins> match self { ImplSource::UserDefined(i) => &i.nested, ImplSource::Param(n, _) => n, </ins> ImplSource::Builtin(i) => &i.nested, ImplSource::AutoImpl(d) => &d.nested, ImplSource::Closure(c) => &c.nested,

} } <ins> pub fn borrow_nested_obligations_mut(&mut self) -> &mut [N] { match self { ImplSource::UserDefined(i) => &mut i.nested, ImplSource::Param(n, _) => n, ImplSource::Builtin(i) => &mut i.nested, ImplSource::AutoImpl(d) => &mut d.nested, ImplSource::Closure(c) => &mut c.nested, ImplSource::Generator(c) => &mut c.nested, ImplSource::Future(c) => &mut c.nested, ImplSource::Object(d) => &mut d.nested, ImplSource::FnPointer(d) => &mut d.nested, ImplSource::TraitAlias(d) => &mut d.nested, ImplSource::TraitUpcasting(d) => &mut d.nested, ImplSource::ConstDestruct(i) => &mut i.nested, } } </ins> pub fn map<M, F>(self, f: F) -> ImplSource<'tcx, M> where F: FnMut(N) -> M,

} }; <ins> // The obligations returned by confirmation are recursively evaluated // so we need to make sure they have the correct depth. for subobligation in impl_src.borrow_nested_obligations_mut() { subobligation.set_depth_from_parent(obligation.recursion_depth); } </ins> if !obligation.predicate.is_const_if_const() { // normalize nested predicates according to parent predicate's constness. impl_src = impl_src.map(|mut o| {

<del> error[E0275]: overflow evaluating the requirement `RootDatabase: RefUnwindSafe` </del> <ins> error[E0275]: overflow evaluating the requirement `SalsaStorage: RefUnwindSafe` </ins> --> $DIR/cycle-cache-err-60010.rs:27:13 | LL |     _parse: <ParseQuery as Query<RootDatabase>>::Data, |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | <ins> note: required because it appears within the type `PhantomData<SalsaStorage>` --> $SRC_DIR/core/src/marker.rs:LL:COL note: required because it appears within the type `Unique<SalsaStorage>` --> $SRC_DIR/core/src/ptr/unique.rs:LL:COL note: required because it appears within the type `Box<SalsaStorage>` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL note: required because it appears within the type `Runtime<RootDatabase>` --> $DIR/cycle-cache-err-60010.rs:23:8 | LL | struct Runtime<DB: Database> { |        ^^^^^^^ note: required because it appears within the type `RootDatabase` --> $DIR/cycle-cache-err-60010.rs:20:8 | LL | struct RootDatabase { |        ^^^^^^^^^^^^ </ins> note: required for `RootDatabase` to implement `SourceDatabase` --> $DIR/cycle-cache-err-60010.rs:44:9 |

<ins> //~ ERROR overflow // A regression test for #111729 checking that we correctly // track recursion depth for obligations returned by confirmation. use std::panic::RefUnwindSafe; trait Database { type Storage; } trait Query<DB> { type Data; } struct ParseQuery; struct RootDatabase { _runtime: Runtime<RootDatabase>, } impl<T: RefUnwindSafe> Database for T { type Storage = SalsaStorage; } impl Database for RootDatabase { type Storage = SalsaStorage; } struct Runtime<DB: Database> { _storage: Box<DB::Storage>, } struct SalsaStorage { _parse: <ParseQuery as Query<RootDatabase>>::Data, } impl<DB: Database> Query<DB> for ParseQuery { type Data = RootDatabase; } fn main() {} </ins>

<ins> error[E0275]: overflow evaluating the requirement `Runtime<RootDatabase>: RefUnwindSafe` | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`cycle_via_builtin_auto_trait_impl`) note: required because it appears within the type `RootDatabase` --> $DIR/cycle-via-builtin-auto-trait-impl.rs:13:8 | LL | struct RootDatabase { |        ^^^^^^^^^^^^ note: required for `RootDatabase` to implement `Database` --> $DIR/cycle-via-builtin-auto-trait-impl.rs:17:24 | LL | impl<T: RefUnwindSafe> Database for T { |         -------------  ^^^^^^^^     ^ |         | |         unsatisfied trait bound introduced here note: required because it appears within the type `Runtime<RootDatabase>` --> $DIR/cycle-via-builtin-auto-trait-impl.rs:24:8 | LL | struct Runtime<DB: Database> { |        ^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0275`. </ins>