about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAgustin Fernandez <juan.fernandez@opower.com>2019-10-28 09:15:46 -0400
committerAgustin Fernandez <juan.fernandez@opower.com>2019-10-28 15:49:22 -0400
commitf1aa8b2c01a97b0114f84b2d557e4598e6070515 (patch)
tree55fcd897220774e64611e7a7656446743738cfbb
parentfae75cd216c481de048e4951697c8f8525669c65 (diff)
downloadrust-f1aa8b2c01a97b0114f84b2d557e4598e6070515.tar.gz
rust-f1aa8b2c01a97b0114f84b2d557e4598e6070515.zip
Output previous stable error messaging when using stable build.
-rw-r--r--src/librustc/hir/lowering/expr.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/librustc/hir/lowering/expr.rs b/src/librustc/hir/lowering/expr.rs
index d5fcc0ef6ed..73db762a64b 100644
--- a/src/librustc/hir/lowering/expr.rs
+++ b/src/librustc/hir/lowering/expr.rs
@@ -235,11 +235,20 @@ impl LoweringContext<'_> {
     /// ```
     fn lower_expr_let(&mut self, span: Span, pat: &Pat, scrutinee: &Expr) -> hir::ExprKind {
         // If we got here, the `let` expression is not allowed.
-        self.sess
-            .struct_span_err(span, "`let` expressions are not supported here")
-            .note("only supported directly in conditions of `if`- and `while`-expressions")
-            .note("as well as when nested within `&&` and parenthesis in those conditions")
-            .emit();
+
+        if self.sess.opts.unstable_features.is_nightly_build() {
+            self.sess
+                .struct_span_err(span, "`let` expressions are not supported here")
+                .note("only supported directly in conditions of `if`- and `while`-expressions")
+                .note("as well as when nested within `&&` and parenthesis in those conditions")
+                .emit();
+        }
+        else {
+            self.sess
+                .struct_span_err(span, "expected expression, found statement (`let`)")
+                .note("variable declaration using `let` is a statement")
+                .emit();
+        }
 
         // For better recovery, we emit:
         // ```