Repository navigation
Conversation
dropping_formula_for_term cut recursion only at a variant field that is directly a pointer to an enum with the same symbol. A recursive enum reached any other way recursed forever and overflowed the stack: through a tuple field (#178), through another enum such as `Node(i64, Option<Box<Node>>)`, or through a mutually recursive enum. The symbol-only check also treated a pointer to another instantiation of the same generic enum as recursive, leaving the `&mut` in `Option<&mut Option<i64>>` unresolved (#341). Track the sorts of the enums whose drop formula is being built, and skip an enum only when its sort is already among them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hw71PvaCsVX6Gv13CKahEf
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This branch has not been deployed
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.
Fixes #178. Also fixes #341.
Env::dropping_formula_for_termonly cut recursion at a variant field that is directly a pointer to an enum with the same symbol. That caused two problems:Cons((i64, Box<L>)), Stack overflow (non-termination) indropping_formula_for_termwhen a recursive ADT's self-pointer is nested inside a tuple/struct field #178), through another enum (Node(i64, Option<Box<Node>>), the usual optional-child shape), or through a mutually recursive enum (A::Wrap(Box<B>),B::Back(Box<A>)). Details are in this comment on #178.&mut. The check looked at the symbol only, so it also skipped a pointer to a different instantiation of the same generic enum. That left the&mutinOption<&mut Option<i64>>unresolved (Incompleteness: dropping a generic enum skips any field pointing to another instantiation of the same enum as "recursive", so the&mutinOption<&mut Option<T>>/Option<Box<Option<&mut T>>>is never resolved and the owner is havoc'd #341).This PR passes a stack of the sorts of the enums whose drop formula is being built. An enum is skipped only when its sort is already on that stack. The direct
Box<Self>case is skipped the same way it was before, now by the guard. Every other path back to an enclosing enum is cut too, and a different instantiation is recursed into. Skipping still only leaves a prophecy unresolved, so it stays sound, as the existing skip was.This overlaps with #342, which fixes #341 by comparing the pointee's sort. It doesn't help the overflow cases, because there the field that leads back is not a pointer to the enum being dropped.
Tests
tests/ui/{pass,fail}/enum_recursive_through_option.rs(Link(i64, Option<Box<Chain>>)). The pass file overflows the stack onmain.dropping_formula_for_termwhen a recursive ADT's self-pointer is nested inside a tuple/struct field #178 and Incompleteness: dropping a generic enum skips any field pointing to another instantiation of the same enum as "recursive", so the&mutinOption<&mut Option<T>>/Option<Box<Option<&mut T>>>is never resolved and the owner is havoc'd #341 and the mutually recursive pair now verify assafe.cargo testpasses locally: 402 UI tests, with Z3 5.0.0 and the pinned PCSat.cargo fmt --checkandcargo clippy -- -D warningsare clean.Generated by Claude Code