]> git.lizzy.rs Git - rust.git/commit
Auto merge of #37400 - eddyb:lazy-1, r=nikomatsakis
authorbors <bors@rust-lang.org>
Sun, 30 Oct 2016 03:46:20 +0000 (20:46 -0700)
committerGitHub <noreply@github.com>
Sun, 30 Oct 2016 03:46:20 +0000 (20:46 -0700)
commitef6f74340762f145f780aeb1b549030bd84c5beb
tree87fd679a4c6d808457fe192abdd96b0d7c37d5bb
parent248e7b302a92da0ae829560fde721a62119c2c65
parente34792b181ab6af0221c0fb35940b1cc5dc476e1
Auto merge of #37400 - eddyb:lazy-1, r=nikomatsakis

[1/n] Move the MIR map into the type context.

*This is part of a series ([prev]() | [next](https://github.com/rust-lang/rust/pull/37401)) of patches designed to rework rustc into an out-of-order on-demand pipeline model for both better feature support (e.g. [MIR-based](https://github.com/solson/miri) early constant evaluation) and incremental execution of compiler passes (e.g. type-checking), with beneficial consequences to IDE support as well.
If any motivation is unclear, please ask for additional PR description clarifications or code comments.*
<hr>

The first commit reorganizes the `rustc::mir` module to contain the MIR types directly without an extraneous `repr` module which serves no practical purpose but is rather an eyesore.

The second commit performs the actual move of the MIR map into the type context, for the purposes of future integration with requesting analysis/lowering by-products through `TyCtxt`.

Local `Mir` bodies need to be mutated by passes (hence `RefCell`), and at least one pass (`qualify_consts`) needs simultaneous access to multiple `Mir` bodies (hence arena-allocation).
`Mir` bodies loaded from other crates appear as if immutably borrowed (by `.borrow()`-ing one `Ref` and subsequently "leaking" it) to avoid, at least dynamically, *any* possibility of their local mutation.

One caveat is that lint passes can now snoop at the MIR (helpful) or even mutate it (dangerous).
However, lints are unstable anyway and we can find a way to deal with this in due time.
Future work will result in a tighter API, potentially hiding mutation *completely* outside of MIR passes.
src/librustc_metadata/decoder.rs