-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Implement match condition #861
base: main
Are you sure you want to change the base?
Conversation
The golden IRs have changed: a68dbb9..3e506fd |
@@ -744,6 +744,7 @@ pub fn format_cst<'a>( | |||
} | |||
CstKind::MatchCase { | |||
pattern, | |||
condition: _, // TODO: format match case conditions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened a follow-up issue: #868
compiler/frontend/src/mir/body.rs
Outdated
&mut self, | ||
hir_id: &hir::Id, | ||
condition: Id, | ||
else_builder: E, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can inline the constraint so there are no type parameters anymore.
else_builder: E, | |
else_builder: impl FnOnce(&mut Self), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I also apply this to the rest of this class (I was matching the style of other methods in this class)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should eventually use it where applicable, but that can be done over time. I think the feature is relatively recent, so we only used it for new code and didn't update everything yet
compiler/frontend/src/rcst.rs
Outdated
@@ -17,7 +17,7 @@ impl From<CstKind<()>> for Cst<()> { | |||
|
|||
impl ToRichIr for Rcst { | |||
fn build_rich_ir(&self, builder: &mut RichIrBuilder) { | |||
builder.push(format!("{self:?}"), None, EnumSet::empty()); | |||
builder.push(format!("{self:#?}"), None, EnumSet::empty()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CST's rich IR is currently messed up and I suspect it comes from this change
let (input, condition) = if let Some((input, condition_comma)) = comma(input) { | ||
let (input, whitespace) = whitespaces_and_newlines(input, indentation, true); | ||
let condition_comma = condition_comma.wrap_in_whitespace(whitespace); | ||
if let Some((input, condition_expresion)) = expression( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small typo: condition_expresion
is missing one “s”
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you completely addressed a review comment and didn't write an answer, you can directly resolve the conversation yourself
compiler/frontend/src/hir_to_mir.rs
Outdated
// something % | ||
// foo -> ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// something % | |
// foo -> ... | |
// foo = … | |
// | |
// or: | |
// | |
// something % | |
// foo -> ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to further up in this file
7f46941
to
38f30f4
Compare
Closes: #659
Added optional condtions to match cases in RCST, AST, and HIR, which are resolved to if/else in MIR.
Checklist