Description
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
anOption
? What does it mean when there is aNone
there and when does that happen? - Why does
EvalSnapshot::new
make a deep copy, and then it has a methodEvalSnapshot::snapshot
that does a snapshot (of theEvalSnapshot
, confusing naming)? That method is called inPartialEq::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.