[−][src]Function rustc_mir_build::thir::pattern::_match::specialize_one_pattern
fn specialize_one_pattern<'p, 'tcx>(
cx: &mut MatchCheckCtxt<'p, 'tcx>,
pat: &'p Pat<'tcx>,
constructor: &Constructor<'tcx>,
ctor_wild_subpatterns: &Fields<'p, 'tcx>
) -> Option<Fields<'p, 'tcx>>
This is the main specialization step. It expands the pattern
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.
Returns None if the pattern does not have the given constructor.
OTOH, slice patterns with a subslice pattern (tail @ ..) can be expanded into multiple different patterns. Structure patterns with a partial wild pattern (Foo { a: 42, .. }) have their missing fields filled with wild patterns.
This is roughly the inverse of Constructor::apply.