Preventing infinite inlining of cycle functions.#9917
Conversation
PR SummaryMedium Risk Overview Extends the lowering test runner with a Reviewed by Cursor Bugbot for commit 7789074. Bugbot is set up for automated code reviews on this repo. Configure here. |
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware reviewed 4 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on orizi).
a9293b1 to
7789074
Compare

Summary
Fixes a hang that occurred when lowering self-referential
Destructimplementations in no-gas mode (issue #9894). The cycle detection for inlining now usesLoweringStage::PreOptimizationsinstead ofLoweringStage::Monomorphized, which correctly identifies recursive destructors as cyclic and prevents infinite inlining. The TODO comment about needing better logic to avoid inlining destructors that call themselves has been removed, as this fix addresses that concern.A
no_gastest flag and correspondingLoweringDatabaseForTesting::with_no_gas()snapshot are introduced to enable lowering tests that disablewithdraw_gasinsertion, along with a regression test covering the self-referentialDestructcase.Type of change
Please check one:
Why is this change needed?
In no-gas mode, a struct with a
Destructimpl that calls itself (directly or indirectly) caused the compiler to hang indefinitely during inlining. The cycle check was running againstLoweringStage::Monomorphized, which did not detect the cycle at the point where inlining decisions are made, allowing unbounded recursive inlining attempts.What was the behavior or documentation before?
Compiling a self-referential
Destructimpl with gas disabled would cause the compiler to hang without producing diagnostics or output.What is the behavior or documentation after?
The compiler correctly detects the cycle, skips inlining for the recursive destructor, and produces valid lowered output without hanging.
Related issue or discussion (if any)
Fixes #9894
Additional context
The
SHARED_DBstatic intest_utils.rswas also changed frompubto private, as it was not intended to be part of the public API.