Module rustc_mir::util::liveness[][src]

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Liveness analysis which computes liveness of MIR local variables at the boundary of basic blocks

This analysis considers references as being used only at the point of the borrow. This means that this does not track uses because of references that already exist:

    fn foo() {
        x = 0;
        // `x` is live here
        GLOBAL = &x: *const u32;
        // but not here, even while it can be accessed through `GLOBAL`.
        foo();
        x = 1;
        // `x` is live again here, because it is assigned to `OTHER_GLOBAL`
        OTHER_GLOBAL = &x: *const u32;
        // ...
    }

This means that users of this analysis still have to check whether pre-existing references can be used to access the value (e.g. at movable generator yield points, all pre-existing references are invalidated, so this doesn't matter).

Re-exports

use rustc::mir::*;
use rustc::mir::visit::PlaceContext;
use rustc::mir::visit::Visitor;
use rustc_data_structures::indexed_vec::Idx;
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_data_structures::indexed_set::IdxSetBuf;
use util::pretty::dump_enabled;
use util::pretty::write_basic_block;
use util::pretty::write_mir_intro;
use rustc::ty::item_path;
use rustc::mir::visit::MirVisitable;
use std::path::Path;
use std::path::PathBuf;
use std::fs;
use rustc::ty::TyCtxt;
use std::io;
use std::io::Write;
use transform::MirSource;

Structs

DefsUses [
Experimental
]
DefsUsesVisitor [
Experimental
]
LivenessMode [
Experimental
]
LivenessResult [
Experimental
]

This gives the result of the liveness analysis at the boundary of basic blocks. You can use simulate_block to obtain the intra-block results.

LivenessResults [
Experimental
]

A combination of liveness results, used in NLL.

Enums

DefUse [
Experimental
]

Functions

block [
Experimental
]
categorize [
Experimental
]
dump_matched_mir_node [
Experimental
]
dump_mir [
Experimental
]
liveness_of_locals [
Experimental
]

Compute which local variables are live within the given function mir. The liveness mode mode determines what sorts of uses are considered to make a variable live (e.g., do drops count?).

write_mir_fn [
Experimental
]

Type Definitions

LocalSet [
Experimental
]