Module matches

Source
Expand description

Code related to match expressions. These are sufficiently complex to warrant their own module and submodules. :) This main module includes the high-level algorithm, the submodules contain the details.

This also includes code for pattern bindings in let statements and function parameters.

ModulesΒ§

match_pair πŸ”’
test πŸ”’
user_ty πŸ”’
Helper code for building a linked list of user-type projections on the stack while visiting a THIR pattern.
util πŸ”’

StructsΒ§

ArmHasGuard πŸ”’
ArmHasGuard is a wrapper around a boolean flag. It indicates whether a match arm has a guard expression attached to it.
Ascription πŸ”’
Indicates that the type of source must be a subtype of the user-given type user_ty; this is basically a no-op but can influence region inference.
Binding πŸ”’
BuiltMatchTree πŸ”’
The result of generating MIR for a pattern-matching expression. Each input branch/arm/pattern gives rise to an output MatchTreeBranch. If one of the patterns matches, we branch to the corresponding success_block. If none of the patterns matches, we branch to otherwise_block.
Candidate πŸ”’
Candidates are a generalization of (a) top-level match arms, and (b) sub-branches of or-patterns, allowing the match-lowering process to handle them both in a mostly-uniform way. For example, the list of candidates passed to Builder::match_candidates will often contain a mixture of top-level candidates and or-pattern subcandidates.
FlatPat πŸ”’
A pattern in a form suitable for lowering the match tree, with all irrefutable patterns simplified away.
MatchPairTree πŸ”’
Node in a tree of β€œmatch pairs”, where each pair consists of a place to be tested, and a test to perform on that place.
MatchTreeBranch πŸ”’
A branch in the output of match lowering.
MatchTreeSubBranch πŸ”’
A sub-branch in the output of match lowering. Match lowering has generated MIR code that will branch to success_block when the matched value matches the corresponding pattern. If there is a guard, its failure must continue to otherwise_block, which will resume testing patterns.
PatternExtraData πŸ”’
Data extracted from a pattern that doesn’t affect which branch is taken. Collected during pattern simplification and not mutated later.
Test πŸ”’
A test to perform to determine which Candidate matches a value.
ThenElseArgs πŸ”’
Arguments to Builder::then_else_break_inner that are usually forwarded to recursive invocations.

EnumsΒ§

DeclareLetBindings πŸ”’
Should lowering a let expression also declare its bindings?
EmitStorageLive πŸ”’
Used by Builder::bind_matched_candidate_for_arm_body to determine whether or not to call Builder::storage_live_binding to emit StatementKind::StorageLive.
HasMatchGuard πŸ”’
ScheduleDrops πŸ”’
Used by Builder::storage_live_binding and Builder::bind_matched_candidate_for_arm_body to decide whether to schedule drops.
TestBranch πŸ”’
The branch to be taken after a test.
TestCase πŸ”’
Partial summary of a thir::Pat, indicating what sort of test should be performed to match/reject the pattern, and what the desired test outcome is. This avoids having to perform a full match on thir::PatKind in some places, and helps TestKind::Switch and TestKind::SwitchInt know what target values to use.
TestKind πŸ”’
See Test for more.

FunctionsΒ§

traverse_candidate πŸ”’
A depth-first traversal of the Candidate and all of its recursive subcandidates.