about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorBarosl Lee <vcs@barosl.com>2014-12-20 01:42:21 +0900
committerBarosl Lee <vcs@barosl.com>2014-12-20 09:17:14 +0900
commit7023bea22c969a324d7d95d8794370410ff7c4c9 (patch)
tree81cf841e8b8a055ea0517888c1daddadd6469e5f /src/libsyntax
parentcbe9fb45bc705a89f23b434c686544d490923596 (diff)
downloadrust-7023bea22c969a324d7d95d8794370410ff7c4c9.tar.gz
rust-7023bea22c969a324d7d95d8794370410ff7c4c9.zip
Print a friendly error for the if-let construct without an else block
Fixes #19991.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs2
-rw-r--r--src/libsyntax/ext/expand.rs4
2 files changed, 4 insertions, 2 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index be8f32bc4d5..ab338da63bf 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -754,7 +754,7 @@ pub struct QPath {
 #[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum MatchSource {
     MatchNormal,
-    MatchIfLetDesugar,
+    MatchIfLetDesugar(bool /* contains_else_arm */),
     MatchWhileLetDesugar,
 }
 
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 20c8ff20b71..63bd38de8a0 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -170,7 +170,9 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
             arms.extend(else_if_arms.into_iter());
             arms.push(else_arm);
 
-            let match_expr = fld.cx.expr(span, ast::ExprMatch(expr, arms, ast::MatchIfLetDesugar));
+            let match_expr = fld.cx.expr(span, ast::ExprMatch(expr,
+                                                              arms,
+                                                    ast::MatchIfLetDesugar(elseopt.is_some())));
             fld.fold_expr(match_expr)
         }