rustc_pattern_analysis::rustc

Type Alias ConstructorSet

Source
pub type ConstructorSet<'p, 'tcx> = ConstructorSet<RustcPatCtxt<'p, 'tcx>>;

Aliased Type§

enum ConstructorSet<'p, 'tcx> {
    Struct {
        empty: bool,
    },
    Variants {
        variants: IndexVec<VariantIdx, VariantVisibility>,
        non_exhaustive: bool,
    },
    Ref,
    Union,
    Bool,
    Integers {
        range_1: IntRange,
        range_2: Option<IntRange>,
    },
    Slice {
        array_len: Option<usize>,
        subtype_is_empty: bool,
    },
    Unlistable,
    NoConstructors,
}

Variants§

§

Struct

The type is a tuple or struct. empty tracks whether the type is empty.

Fields

§empty: bool
§

Variants

This type has the following list of constructors. If variants is empty and non_exhaustive is false, don’t use this; use NoConstructors instead.

Fields

§variants: IndexVec<VariantIdx, VariantVisibility>
§non_exhaustive: bool
§

Ref

The type is &T.

§

Union

The type is a union.

§

Bool

Booleans.

§

Integers

The type is spanned by integer values. The range or ranges give the set of allowed values. The second range is only useful for char.

Fields

§range_1: IntRange
§range_2: Option<IntRange>
§

Slice

The type is matched by slices. array_len is the compile-time length of the array, if known. If subtype_is_empty, all constructors are empty except possibly the zero-length slice [].

Fields

§array_len: Option<usize>
§subtype_is_empty: bool
§

Unlistable

The constructors cannot be listed, and the type cannot be matched exhaustively. E.g. str, floats.

§

NoConstructors

The type has no constructors (not even empty ones). This is ! and empty enums.

Layout§

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: 128 bytes

Size for each variant:

  • Struct: 17 bytes
  • Variants: 48 bytes
  • Ref: 0 bytes
  • Union: 0 bytes
  • Bool: 0 bytes
  • Integers: 128 bytes
  • Slice: 40 bytes
  • Unlistable: 0 bytes
  • NoConstructors: 0 bytes

Implementations

Source§

impl<Cx: PatCx> ConstructorSet<Cx>

Source

pub fn split<'a>( &self, ctors: impl Iterator<Item = &'a Constructor<Cx>> + Clone, ) -> SplitConstructorSet<Cx>
where Cx: 'a,

This analyzes a column of constructors to 1/ determine which constructors of the type (if any) are missing; 2/ split constructors to handle non-trivial intersections e.g. on ranges or slices. This can get subtle; see SplitConstructorSet for details of this operation and its invariants.

Source

pub(crate) fn all_empty(&self) -> bool

Whether this set only contains empty constructors.

Trait Implementations

Source§

impl<Cx: Debug + PatCx> Debug for ConstructorSet<Cx>
where Cx::VariantIdx: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more