struct WitnessStack<Cx: PatCx>(Vec<WitnessPat<Cx>>);
Expand description
A witness-tuple of non-exhaustiveness for error reporting, represented as a list of patterns (in reverse order of construction).
This mirrors PatStack
: they function similarly, except PatStack
contains user patterns we
are inspecting, and WitnessStack
contains witnesses we are constructing.
FIXME(Nadrieril): use the same order of patterns for both.
A WitnessStack
should have the same types and length as the PatStack
s we are inspecting
(except we store the patterns in reverse order). The same way PatStack
starts with length 1,
at the end of the algorithm this will have length 1. In the middle of the algorithm, it can
contain multiple patterns.
For example, if we are constructing a witness for the match against
struct Pair(Option<(u32, u32)>, bool);
match p {
Pair(None, _) => {}
Pair(_, false) => {}
}
We’ll perform the following steps (among others):
- Start with a matrix representing the match
`PatStack(vec![Pair(None, _)])`
`PatStack(vec![Pair(_, false)])`
- Specialize with `Pair`
`PatStack(vec![None, _])`
`PatStack(vec![_, false])`
- Specialize with `Some`
`PatStack(vec![_, false])`
- Specialize with `_`
`PatStack(vec![false])`
- Specialize with `true`
// no patstacks left
- This is a non-exhaustive match: we have the empty witness stack as a witness.
`WitnessStack(vec![])`
- Apply `true`
`WitnessStack(vec![true])`
- Apply `_`
`WitnessStack(vec![true, _])`
- Apply `Some`
`WitnessStack(vec![true, Some(_)])`
- Apply `Pair`
`WitnessStack(vec![Pair(Some(_), true)])`
The final Pair(Some(_), true)
is then the resulting witness.
See the top of the file for more detailed explanations and examples.
Tuple Fields§
§0: Vec<WitnessPat<Cx>>
Implementations§
source§impl<Cx: PatCx> WitnessStack<Cx>
impl<Cx: PatCx> WitnessStack<Cx>
sourcefn single_pattern(self) -> WitnessPat<Cx>
fn single_pattern(self) -> WitnessPat<Cx>
Asserts that the witness contains a single pattern, and returns it.
sourcefn push_pattern(&mut self, pat: WitnessPat<Cx>)
fn push_pattern(&mut self, pat: WitnessPat<Cx>)
Reverses specialization by the Missing
constructor by pushing a whole new pattern.
sourcefn apply_constructor(
self,
pcx: &PlaceCtxt<'_, Cx>,
ctor: &Constructor<Cx>,
) -> SmallVec<[Self; 1]>
fn apply_constructor( self, pcx: &PlaceCtxt<'_, Cx>, ctor: &Constructor<Cx>, ) -> SmallVec<[Self; 1]>
Reverses specialization. Given a witness obtained after specialization, this constructs a
new witness valid for before specialization. See the section on unspecialize
at the top of
the file.
Examples:
ctor: tuple of 2 elements
pats: [false, "foo", _, true]
result: [(false, "foo"), _, true]
ctor: Enum::Variant { a: (bool, &'static str), b: usize}
pats: [(false, "foo"), _, true]
result: [Enum::Variant { a: (false, "foo"), b: _ }, true]
Trait Implementations§
source§impl<Cx: PatCx> Clone for WitnessStack<Cx>
impl<Cx: PatCx> Clone for WitnessStack<Cx>
Auto Trait Implementations§
impl<Cx> DynSend for WitnessStack<Cx>
impl<Cx> DynSync for WitnessStack<Cx>
impl<Cx> Freeze for WitnessStack<Cx>
impl<Cx> RefUnwindSafe for WitnessStack<Cx>where
<Cx as PatCx>::Ty: RefUnwindSafe,
<Cx as PatCx>::VariantIdx: RefUnwindSafe,
<Cx as PatCx>::StrLit: RefUnwindSafe,
impl<Cx> Send for WitnessStack<Cx>
impl<Cx> Sync for WitnessStack<Cx>
impl<Cx> Unpin for WitnessStack<Cx>
impl<Cx> UnwindSafe for WitnessStack<Cx>where
<Cx as PatCx>::Ty: UnwindSafe,
<Cx as PatCx>::VariantIdx: UnwindSafe,
<Cx as PatCx>::StrLit: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
source§impl<T> Filterable for T
impl<T> Filterable for T
source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<P> IntoQueryParam<P> for P
impl<P> IntoQueryParam<P> for P
fn into_query_param(self) -> P
source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
source§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
source§impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
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: 24 bytes