Module rustc_mir::hair[][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?

The MIR is translated from some high-level abstract IR (HAIR). This section defines the HAIR along with a trait for accessing it. The intention is to allow MIR construction to be unit-tested and separated from the Rust source and compiler data structures.

Re-exports

use rustc::mir::BinOp;
use rustc::mir::BorrowKind;
use rustc::mir::Field;
use rustc::mir::Literal;
use rustc::mir::UnOp;
use rustc::hir::def_id::DefId;
use rustc::middle::region;
use rustc::ty::subst::Substs;
use rustc::ty::AdtDef;
use rustc::ty::ClosureSubsts;
use rustc::ty::Region;
use rustc::ty::Ty;
use rustc::ty::GeneratorInterior;
use rustc::hir;
use syntax::ast;
use syntax_pos::Span;
use self::cx::Cx;
pub use self::pattern::BindingMode;
pub use self::pattern::Pattern;
pub use self::pattern::PatternKind;
pub use self::pattern::FieldPattern;

Modules

cx [
Experimental
]

This module contains the code to convert from the wacky tcx data structures into the hair. The builder is generally ignorant of the tcx etc, and instead goes through the Cx for most of its work.

pattern [
Experimental
]

Code to validate patterns/matches

Structs

Arm [
Experimental
]
Block [
Experimental
]
Expr [
Experimental
]

The Hair trait implementor translates their expressions (&'tcx H::Expr) into instances of this Expr enum. This translation can be done basically as lazily or as eagerly as desired: every recursive reference to an expression in this enum is an ExprRef<'tcx>, which may in turn be another instance of this enum (boxed), or else an untranslated &'tcx H::Expr. Note that instances of Expr are very shortlived. They are created by Hair::to_expr, analyzed and converted into MIR, and then discarded.

FieldExprRef [
Experimental
]
FruInfo [
Experimental
]
Stmt [
Experimental
]

Enums

BlockSafety [
Experimental
]
ExprKind [
Experimental
]
ExprRef [
Experimental
]
LintLevel [
Experimental
]
LogicalOp [
Experimental
]
StmtKind [
Experimental
]
StmtRef [
Experimental
]

Traits

Mirror [
Experimental
]

"Mirroring" is the process of converting from a HIR type into one of the HAIR types defined in this file. This is basically a "on the fly" desugaring step that hides a lot of the messiness in the tcx. For example, the mirror of a &'tcx hir::Expr is an Expr<'tcx>.