fix: MIR evaluation of sized &T with recursive const fn#22030
Merged
ChayimFriedman2 merged 1 commit intorust-lang:masterfrom Apr 13, 2026
Merged
fix: MIR evaluation of sized &T with recursive const fn#22030ChayimFriedman2 merged 1 commit intorust-lang:masterfrom
ChayimFriedman2 merged 1 commit intorust-lang:masterfrom
Conversation
Previously, we didn't recurse in Evaluator::create_memory_map() or Evaluator::patch_addresses() when handling references with a known size. This caused problems for hover rendering on const values, which would build a memory map for evaluated allocations and then pretty-printed values by following references through that map. As a result, references in the map still pointed to the original addresses, meaning that the value pretty-printer would see the type parameters before substitution. This could cause stack overflows on well-formed Rust code using recursive const functions. Add a regression test for hovering on a recursive const fn that previously caused stack overflow. Fixes rust-lang#21503 AI disclosure: I used Codex with GPT 5.4 to investigate the issue and write the initial version of this commit.
ChayimFriedman2
approved these changes
Apr 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, we didn't recurse in Evaluator::create_memory_map() or Evaluator::patch_addresses() when handling references with a known size.
This caused problems for hover rendering on const values, which would build a memory map for evaluated allocations and then pretty-printed values by following references through that map.
As a result, references in the map still pointed to the original addresses, meaning that the value pretty-printer would see the type parameters before substitution. This could cause stack overflows on well-formed Rust code using recursive const functions.
Add a regression test for hovering on a recursive const fn that previously caused stack overflow.
Fixes #21503
AI disclosure: I used Codex with GPT 5.4 to investigate the issue and write the initial version of this commit.