-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Implement if let
#16741
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 if let
#16741
Changes from 6 commits
34301b7
ac200e6
89b29f4
e497a9d
0274c70
21852e4
a5daf17
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 |
---|---|---|
|
@@ -70,6 +70,8 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[ | |
("unboxed_closures", Active), | ||
("import_shadowing", Active), | ||
|
||
("if_let", Active), | ||
|
||
// if you change this list without updating src/doc/rust.md, cmr will be sad | ||
|
||
// A temporary feature gate used to enable parser extensions needed | ||
|
@@ -339,6 +341,14 @@ impl<'a> Visitor<()> for Context<'a> { | |
"unboxed closures are a work-in-progress \ | ||
feature with known bugs"); | ||
} | ||
ast::ExprIfLet(..) | | ||
ast::ExprMatch(_, _, ast::MatchIfLetDesugar) => { | ||
// note: at the point where we check feature-gates, the AST desugaring | ||
// should not have happened, but the ExprMatch check is included just | ||
// in case. | ||
self.gate_feature("if_let", e.span, | ||
"`if let` desugaring is experimental"); | ||
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. remove 'desugaring' 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'll replace it with 'syntax', so it says |
||
} | ||
_ => {} | ||
} | ||
visit::walk_expr(self, e, ()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -356,7 +356,9 @@ impl<'d,'t,TYPER:mc::Typer> ExprUseVisitor<'d,'t,TYPER> { | |
} | ||
} | ||
|
||
ast::ExprMatch(ref discr, ref arms) => { | ||
ast::ExprIfLet(..) => fail!("non-desugared ExprIfLet"), | ||
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. better for these 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. This was based on the recently-removed |
||
|
||
ast::ExprMatch(ref discr, ref arms, _) => { | ||
// treatment of the discriminant is handled while | ||
// walking the arms: | ||
self.walk_expr(&**discr); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region) | |
ast::ExprMethodCall(..) => { | ||
explain_span(cx, "method call", expr.span) | ||
}, | ||
ast::ExprMatch(_, _, ast::MatchIfLetDesugar) => explain_span(cx, "if let", expr.span), | ||
ast::ExprMatch(..) => explain_span(cx, "match", expr.span), | ||
_ => explain_span(cx, "expression", expr.span) | ||
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. Should there be a 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 actually don't know what this bit of code is doing, so I don't know how to test it, but I assume it's only ever called on the post-desugared AST. The old |
||
} | ||
|
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.
replace 'desugaring syntax' with 'feature' or 'statement' - the fact that it is implemented with desugaring is not relevant to the user