File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -2134,6 +2134,12 @@ impl<'a> Parser<'a> {
2134
2134
}
2135
2135
hi = self . last_span . hi ;
2136
2136
}
2137
+ _ if self . token . is_keyword ( keywords:: Let ) => {
2138
+ // Catch this syntax error here, instead of in `check_strict_keywords`, so that
2139
+ // we can explicitly mention that let is not to be used as an expression
2140
+ let msg = "`let` is not an expression, so it cannot be used in this way" ;
2141
+ return Err ( self . diagnostic ( ) . struct_span_err ( self . span , & msg) ) ;
2142
+ } ,
2137
2143
_ => {
2138
2144
if self . eat_lt ( ) {
2139
2145
let ( qself, path) =
@@ -2199,12 +2205,6 @@ impl<'a> Parser<'a> {
2199
2205
UnsafeBlock ( ast:: UserProvided ) ,
2200
2206
attrs) ;
2201
2207
}
2202
- if self . eat_keyword ( keywords:: Let ) {
2203
- return Err ( self . span_fatal ( self . span ,
2204
- "`let` is not an expression, so it cannot \
2205
- be used in this way") )
2206
-
2207
- }
2208
2208
if self . eat_keyword ( keywords:: Return ) {
2209
2209
if self . token . can_begin_expr ( ) {
2210
2210
let e = try!( self . parse_expr ( ) ) ;
You can’t perform that action at this time.
0 commit comments