Skip to content

Commit f1aa8b2

Browse files
author
Agustin Fernandez
committed
Output previous stable error messaging when using stable build.
1 parent fae75cd commit f1aa8b2

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/librustc/hir/lowering/expr.rs

+14-5
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,20 @@ impl LoweringContext<'_> {
235235
/// ```
236236
fn lower_expr_let(&mut self, span: Span, pat: &Pat, scrutinee: &Expr) -> hir::ExprKind {
237237
// If we got here, the `let` expression is not allowed.
238-
self.sess
239-
.struct_span_err(span, "`let` expressions are not supported here")
240-
.note("only supported directly in conditions of `if`- and `while`-expressions")
241-
.note("as well as when nested within `&&` and parenthesis in those conditions")
242-
.emit();
238+
239+
if self.sess.opts.unstable_features.is_nightly_build() {
240+
self.sess
241+
.struct_span_err(span, "`let` expressions are not supported here")
242+
.note("only supported directly in conditions of `if`- and `while`-expressions")
243+
.note("as well as when nested within `&&` and parenthesis in those conditions")
244+
.emit();
245+
}
246+
else {
247+
self.sess
248+
.struct_span_err(span, "expected expression, found statement (`let`)")
249+
.note("variable declaration using `let` is a statement")
250+
.emit();
251+
}
243252

244253
// For better recovery, we emit:
245254
// ```

0 commit comments

Comments
 (0)