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

Re-exports

use self::Constructor::*;
use self::Usefulness::*;
use self::WitnessPreference::*;
use rustc::middle::const_val::ConstVal;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::indexed_vec::Idx;
use super::FieldPattern;
use super::Pattern;
use super::PatternKind;
use super::PatternFoldable;
use super::PatternFolder;
use super::compare_const_vals;
use rustc::hir::def_id::DefId;
use rustc::hir::RangeEnd;
use rustc::ty;
use rustc::ty::Ty;
use rustc::ty::TyCtxt;
use rustc::ty::TypeFoldable;
use rustc::mir::Field;
use rustc::util::common::ErrorReported;
use syntax_pos::Span;
use syntax_pos::DUMMY_SP;
use arena::TypedArena;
use std::cmp;
use std::cmp::Ordering;
use std::fmt;
use std::iter::FromIterator;
use std::iter::IntoIterator;
use std::iter::repeat;

Structs

LiteralExpander [
Experimental
]
MatchCheckCtxt [
Experimental
]
Matrix [
Experimental
]
PatternContext [
Experimental
]
Witness [
Experimental
]

A stack of patterns in reverse order of construction

Enums

Constructor [
Experimental
]
Usefulness [
Experimental
]
WitnessPreference [
Experimental
]

Functions

all_constructors [
Experimental
]

This determines the set of all possible constructors of a pattern matching values of type left_ty. For vectors, this would normally be an infinite set but is instead bounded by the maximum fixed length of slice patterns in the column of patterns being analyzed.

constructor_arity [
Experimental
]

This computes the arity of a constructor. The arity of a constructor is how many subpattern patterns of that constructor should be expanded to.

constructor_covered_by_range [
Experimental
]
constructor_sub_pattern_tys [
Experimental
]

This computes the types of the sub patterns that a constructor should be expanded to.

expand_pattern [
Experimental
]
is_useful [
Experimental
]

Algorithm from http://moscova.inria.fr/~maranget/papers/warn/index.html The algorithm from the paper has been modified to correctly handle empty types. The changes are: (0) We don't exit early if the pattern matrix has zero rows. We just continue to recurse over columns. (1) all_constructors will only return constructors that are statically possible. eg. it will only return Ok for Result<T, !>

is_useful_specialized [
Experimental
]
max_slice_length [
Experimental
]
pat_constructors [
Experimental
]

Determines the constructors that the given pattern can be specialized to.

patterns_for_variant [
Experimental
]
slice_pat_covered_by_constructor [
Experimental
]
specialize [
Experimental
]

This is the main specialization step. It expands the first pattern in the given row into arity patterns based on the constructor. For most patterns, the step is trivial, for instance tuple patterns are flattened and box patterns expand into their inner pattern.