-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Guard patterns: MIR lowering #154545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Guard patterns: MIR lowering #154545
Changes from 24 commits
9744d19
eaed728
3b5b2eb
22563b8
6fd9b82
3617392
d6f6226
7683944
b094f0d
b2c991e
6e62fe1
9dfaa88
9e5af3e
1bfb34c
49b3d50
4675c33
2235647
ff38c3a
a37a3f9
b4cc11a
e756562
a3b7815
dbe705d
af46f95
9db9f15
00f0ffe
0282eeb
d036e0b
a32bc5b
4d88621
4188f21
cef0cf1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,7 +146,10 @@ impl<'tcx> MatchPairTree<'tcx> { | |
| // or-patterns that will be simplified by `merge_trivial_subcandidates`. In | ||
| // other words, we can assume this expands into subcandidates. | ||
| // FIXME(@dianne): this needs updating/removing if we always merge or-patterns | ||
| extra_data.bindings.push(super::SubpatternBindings::FromOrPattern); | ||
| extra_data.bindings.push(super::OrderedPatternData::FromOrPattern); | ||
| } | ||
| if !pats[0].extra_data.guard_patterns.is_empty() { | ||
| extra_data.guard_patterns.push(super::OrderedPatternData::FromOrPattern); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this check works for guards. For bindings, it relies on the set of bound variables in each alternative being the same. Checking that there's bindings in the first alternative is the same as checking whether any and all alternatives have bindings (assuming the pattern is well-formed). And by checking that there's bindings, we ensure we won't add a I think the simplest thing to do would be have a single check that at least one of the alternatives'
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if I implemented that as you intended, that turns out to be over generalized or smth |
||
| } | ||
| Some(TestableCase::Or { pats }) | ||
| } | ||
|
|
@@ -217,7 +220,7 @@ impl<'tcx> MatchPairTree<'tcx> { | |
|
|
||
| // Then push this binding, after any bindings in the subpattern. | ||
| if let Some(source) = place { | ||
| extra_data.bindings.push(super::SubpatternBindings::One(super::Binding { | ||
| extra_data.bindings.push(super::OrderedPatternData::One(super::Binding { | ||
| span: pattern.span, | ||
| source, | ||
| var_id: var, | ||
|
|
@@ -361,9 +364,10 @@ impl<'tcx> MatchPairTree<'tcx> { | |
| Some(TestableCase::Deref { temp, mutability }) | ||
| } | ||
|
|
||
| PatKind::Guard { .. } => { | ||
| // FIXME(guard_patterns) | ||
| None | ||
| PatKind::Guard { ref subpattern, condition } => { | ||
| MatchPairTree::for_pattern(place_builder, subpattern, cx, match_pairs, extra_data); | ||
| extra_data.guard_patterns.push(super::OrderedPatternData::One(condition)); | ||
| return; | ||
| } | ||
|
|
||
| PatKind::Never => Some(TestableCase::Never), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.