Enum rustc_mir_build::thir::pattern::deconstruct_pat::Constructor[][src]

pub(super) enum Constructor<'tcx> {
    FloatRange(&'tcx Const<'tcx>, &'tcx Const<'tcx>, RangeEnd),
    Str(&'tcx Const<'tcx>),
    Missing {
        nonexhaustive_enum_missing_real_variants: bool,
Expand description

A value can be decomposed into a constructor applied to some fields. This struct represents the constructor. See also Fields.

pat_constructor retrieves the constructor corresponding to a pattern. specialize_constructor returns the list of fields corresponding to a pattern, given a constructor. Constructor::apply reconstructs the pattern from a pair of Constructor and Fields.



The constructor for patterns that have a single constructor, like tuples, struct patterns and fixed-length arrays.


Enum variants.

Tuple Fields of Variant

0: VariantIdx

Ranges of integer literal values (2, 2..=5 or 2..5).

Tuple Fields of IntRange

0: IntRange
FloatRange(&'tcx Const<'tcx>, &'tcx Const<'tcx>, RangeEnd)

Ranges of floating-point literal values (2.0..=5.2).

Tuple Fields of FloatRange

0: &'tcx Const<'tcx>1: &'tcx Const<'tcx>2: RangeEnd
Str(&'tcx Const<'tcx>)

String literals. Strings are not quite the same as &[u8] so we treat them separately.

Tuple Fields of Str

0: &'tcx Const<'tcx>

Array and slice patterns.

Tuple Fields of Slice

0: Slice

Constants that must not be matched structurally. They are treated as black boxes for the purposes of exhaustiveness: we must not inspect them, and they don’t count towards making a match exhaustive.


Fake extra constructor for enums that aren’t allowed to be matched exhaustively. Also used for those types for which we cannot list constructors explicitly, like f64 and str.


Stands for constructors that are not seen in the matrix, as explained in the documentation for SplitWildcard. The carried bool is used for the non_exhaustive_omitted_patterns lint.

Fields of Missing

nonexhaustive_enum_missing_real_variants: bool

Wildcard pattern.




Checks if the Constructor is a variant and TyCtxt::eval_stability returns EvalResult::Deny { .. }.

This means that the variant has a stdlib unstable feature marking it.

Checks if the Constructor is a Constructor::Variant with a #[doc(hidden)] attribute.

The number of fields for this constructor. This must be kept in sync with Fields::wildcards.

Some constructors (namely Wildcard, IntRange and Slice) actually stand for a set of actual constructors (like variants, integers or fixed-sized slices). When specializing for these constructors, we want to be specialising for the actual underlying constructors. Naively, we would simply return the list of constructors they correspond to. We instead are more clever: if there are constructors that we know will behave the same wrt the current matrix, we keep them grouped. For example, all slices of a sufficiently large length will either be all useful or all non-useful with a given matrix.

See the branches for details on how the splitting is done.

This function may discard some irrelevant constructors if this preserves behavior and diagnostics. Eg. for the _ case, we ignore the constructors already present in the matrix, unless all of them are.

Returns whether self is covered by other, i.e. whether self is a subset of other. For the simple cases, this is simply checking for equality. For the “grouped” constructors, this checks for inclusion.

Faster version of is_covered_by when applied to many constructors. used_ctors is assumed to be built from matrix.head_ctors() with wildcards filtered out, and self is assumed to have been split from a wildcard.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

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

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.


Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.

Size: 64 bytes

Size for each variant: