Skip to content

remove CTFE loop detector #54384

Closed
Closed
@RalfJung

Description

@RalfJung

The plan changed to removing the loop detector.

Original issue

The code at https://github.com/rust-lang/rust/blob/master/src/librustc_mir/interpret/snapshot.rs leaves me puzzled and confused after wasting about two hours on it. Open questions are:

  • Why is AllocIdSnapshot an Option? What does it mean when there is a None there and when does that happen?
  • Why does EvalSnapshot::new make a deep copy, and then it has a method EvalSnapshot::snapshot that does a snapshot (of the EvalSnapshot, confusing naming)? That method is called in PartialEq::eq, doesn't that mean we do tons of allocations and copies every time we compare?
  • Where and how does it avoid snapshotting the same allocation twice in one snapshot?

I tried fixing the second point (making a snapshot when EvalSnapshot is created, not when it is compared), but failed to do so as the thing produced by the Snapshot trait isn't actually a snapshot (which I would expect to be a deep, independent copy), but something full of references to somewhere (couldn't figure out where though, just saw the lifetime).

Documentation (inline in the code) should be improved to answer these questions, and if the part about allocating during comparison is correct, that should be fixed.

Cc @oli-obk @brunocodutra

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions