File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
src/librustc/hir/lowering Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff 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 // ```
You can’t perform that action at this time.
0 commit comments