From 15f530728a34d9b32b7c18a9d4ab2bd7cc809653 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 17 Mar 2024 09:56:58 +0100 Subject: [PATCH] collector: move ensure_sufficient_stack out of the loop --- compiler/rustc_monomorphize/src/collector.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index cd9eb4916ce5d..051714e4988ed 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -1433,7 +1433,7 @@ fn create_mono_items_for_default_impls<'tcx>( } } -/// Scans the CTFE alloc in order to find function calls, closures, and drop-glue. +/// Scans the CTFE alloc in order to find function pointers and statics that must be monomorphized. fn collect_alloc<'tcx>(tcx: TyCtxt<'tcx>, alloc_id: AllocId, output: &mut MonoItems<'tcx>) { match tcx.global_alloc(alloc_id) { GlobalAlloc::Static(def_id) => { @@ -1446,11 +1446,11 @@ fn collect_alloc<'tcx>(tcx: TyCtxt<'tcx>, alloc_id: AllocId, output: &mut MonoIt } GlobalAlloc::Memory(alloc) => { trace!("collecting {:?} with {:#?}", alloc_id, alloc); - for &prov in alloc.inner().provenance().ptrs().values() { - rustc_data_structures::stack::ensure_sufficient_stack(|| { + rustc_data_structures::stack::ensure_sufficient_stack(move || { + for &prov in alloc.inner().provenance().ptrs().values() { collect_alloc(tcx, prov.alloc_id(), output); - }); - } + } + }); } GlobalAlloc::Function(fn_instance) => { if should_codegen_locally(tcx, &fn_instance) {