diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2025-06-19 08:47:39 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2025-06-23 08:44:31 +0000 |
| commit | 2074013f44e4b12a0949182d050d3470bd76e4de (patch) | |
| tree | db174cb40989baa8fd4b937e81c8fe80ae7c6133 /compiler/rustc_mir_transform/src/inline | |
| parent | 8a35c7ac5b9b3d311253f2935a4b68ab293dc960 (diff) | |
| download | rust-2074013f44e4b12a0949182d050d3470bd76e4de.tar.gz rust-2074013f44e4b12a0949182d050d3470bd76e4de.zip | |
Only store the LocalDefId instead of the whole instance.
Diffstat (limited to 'compiler/rustc_mir_transform/src/inline')
| -rw-r--r-- | compiler/rustc_mir_transform/src/inline/cycle.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_mir_transform/src/inline/cycle.rs b/compiler/rustc_mir_transform/src/inline/cycle.rs index 4ef41b9ba44..08f3ce5fd67 100644 --- a/compiler/rustc_mir_transform/src/inline/cycle.rs +++ b/compiler/rustc_mir_transform/src/inline/cycle.rs @@ -8,6 +8,7 @@ use rustc_session::Limit; use rustc_span::sym; use tracing::{instrument, trace}; +#[instrument(level = "debug", skip(tcx), ret)] fn should_recurse<'tcx>(tcx: TyCtxt<'tcx>, callee: ty::Instance<'tcx>) -> bool { match callee.def { // If there is no MIR available (either because it was not in metadata or @@ -64,7 +65,7 @@ fn process<'tcx>( caller: ty::Instance<'tcx>, target: LocalDefId, seen: &mut FxHashSet<ty::Instance<'tcx>>, - involved: &mut FxHashSet<ty::Instance<'tcx>>, + involved: &mut FxHashSet<LocalDefId>, recursion_limiter: &mut FxHashMap<DefId, usize>, recursion_limit: Limit, ) -> bool { @@ -122,7 +123,10 @@ fn process<'tcx>( true }; if found_recursion { - involved.insert(callee); + if let Some(callee) = callee.def_id().as_local() { + // Calling `optimized_mir` of a non-local definition cannot cycle. + involved.insert(callee); + } cycle_found = true; } } @@ -135,7 +139,7 @@ fn process<'tcx>( pub(crate) fn mir_callgraph_cyclic<'tcx>( tcx: TyCtxt<'tcx>, root: LocalDefId, -) -> UnordSet<ty::Instance<'tcx>> { +) -> UnordSet<LocalDefId> { assert!( !tcx.is_constructor(root.to_def_id()), "you should not call `mir_callgraph_reachable` on enum/struct constructor functions" |
