Uh oh!
There was an error while loading. Please reload this page.
Remove the requirement that ast->hir lowering be reproducible - #33296
Conversation
b1b28c5 to
ce9e894Comparenagisa
commented
Apr 30, 2016
What’s the purpose of the change? Seems like a potentially plugin-breaking-change to me. |
petrochenkov
commented
Apr 30, 2016
Side note: if |
The purpose is to simplify lowering (by removing the id caching system) and to remove the lowering context from the Also, it will be significantly simpler to do name resolution during lowering if lowering doesn't need to be reproducible. I don't think it's worth the extra complexity needed to be reproducible when we can just use the HIR map to re-lower (almost) any AST node. |
@petrochenkov good point, I added a commit that clears the MTWT tables after lowering for save-analysis. |
0cc3573 to
864b4f8CompareThere was a problem hiding this comment.
I think you can remove this whole module
7a000ee to
522b6edCompare| // all increments being for lowering. This means that you should not call any | ||
| // non-lowering function which will use new node ids. | ||
| // | ||
| // We must also cache gensym'ed Idents to ensure that we get the same Ident |
There was a problem hiding this comment.
Good point, forgot about that -- done.
nrc
commented
May 2, 2016
r+ with that comment removed |
nrc
commented
May 2, 2016
@bors: r+ |
bors
commented
May 2, 2016
📌 Commit ef69ef8 has been approved by |
jseyfried
commented
May 2, 2016
bors
commented
May 2, 2016
Remove the requirement that ast->hir lowering be reproducible This PR changes the ast->hir lowerer to be non-reproducible, and it removes the lowering context's id cache. If the `hir` of an `ast` node needs to be reproduced, we can use the hir map instead of the lowerer -- for example, `tcx.map.expect_expr(expr.id)` instead of `lower_expr(lcx, expr)`. r? @nrc
bors
commented
May 2, 2016
RalfJung
commented
May 6, 2016
What exactly is getting non-reproducible with this change? Does this mean that if I compile the same Rust program twice, I would get two different binaries (as in, binaries that are not bit-for-bit identical)? That would be a huge bummer -- reproducible builds are a cornerstone of building trustworthy binaries. If Rust can't build reproducibly, This is actively used, for example, by the Tor project and some BitCoin clients. it would be unsuited for any application that needs to establish trust in the generated binaries. See https://reproducible-builds.org/ for more details. |
I don't know if Rust has this property, but this PR isn't related to reproducible builds. Lowering is still deterministic after this PR (i.e. it behaves the same when building the same code). This PR changed lowering so that if the same AST node is lowered multiple times during the same build, we aren't guaranteed to get same result. Perhaps a better word would be "idempotent" instead of "reproducible". |
…nique, r=nrc Give `ast::ExprKind::Paren` no-op expressions the same ids as their children. Having `ast::ExprKind::Paren` expressions share ids with their children - reduces the number of unused `NodeId`s in the hir map and - guarantees that `tcx.map.expect_expr(ast_expr.id)` is the hir corresponding to `ast_expr`. This fixes the bug from rust-lang#34327, which was introduced in rust-lang#33296 when I assumed the above guarantee. r? @nrc
This PR changes the ast->hir lowerer to be non-reproducible, and it removes the lowering context's id cache.
If the
hirof anastnode needs to be reproduced, we can use the hir map instead of the lowerer -- for example,tcx.map.expect_expr(expr.id)instead oflower_expr(lcx, expr).r? @nrc