Skip to content

Commit

Permalink
Rollup merge of #126926 - Zalathar:candidate-per-arm, r=Nadrieril
Browse files Browse the repository at this point in the history
Tweak a confusing comment in `create_match_candidates`

This comment was accurate at the time it was written, but various later changes reshuffled things in ways that caused the existing comment to become confusing.

I've therefore tried to clarify that *these* candidates are 1:1 with match arms, while also warning that that isn't the case in general.
  • Loading branch information
compiler-errors authored Jun 25, 2024
2 parents 72965db + 8016940 commit a765000
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions compiler/rustc_mir_build/src/build/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
where
'a: 'pat,
{
// Assemble a list of candidates: there is one candidate per pattern,
// which means there may be more than one candidate *per arm*.
// Assemble the initial list of candidates. These top-level candidates
// are 1:1 with the original match arms, but other parts of match
// lowering also introduce subcandidates (for subpatterns), and will
// also flatten candidates in some cases. So in general a list of
// candidates does _not_ necessarily correspond to a list of arms.
arms.iter()
.copied()
.map(|arm| {
Expand Down

0 comments on commit a765000

Please sign in to comment.