@@ -81,9 +81,11 @@ fn _macros() {
81
81
use_expr ! ( ( let 0 = 1 && 0 == 0 ) ) ;
82
82
//~^ ERROR `let` expressions are not supported here
83
83
//~| ERROR `let` expressions are not supported here
84
+ //~| ERROR expected expression, found `let` statement
84
85
use_expr ! ( ( let 0 = 1 ) ) ;
85
86
//~^ ERROR `let` expressions are not supported here
86
87
//~| ERROR `let` expressions are not supported here
88
+ //~| ERROR expected expression, found `let` statement
87
89
}
88
90
89
91
fn nested_within_if_expr ( ) {
@@ -147,7 +149,8 @@ fn nested_within_if_expr() {
147
149
//~| ERROR mismatched types
148
150
//~| ERROR mismatched types
149
151
150
- if let true = let true = true { } //~ ERROR `let` expressions are not supported here
152
+ if let true = let true = true { }
153
+ //~^ ERROR `let` expressions are not supported here
151
154
}
152
155
153
156
fn nested_within_while_expr ( ) {
@@ -211,7 +214,8 @@ fn nested_within_while_expr() {
211
214
//~| ERROR mismatched types
212
215
//~| ERROR mismatched types
213
216
214
- while let true = let true = true { } //~ ERROR `let` expressions are not supported here
217
+ while let true = let true = true { }
218
+ //~^ ERROR `let` expressions are not supported here
215
219
}
216
220
217
221
fn not_error_because_clarified_intent ( ) {
@@ -225,45 +229,85 @@ fn not_error_because_clarified_intent() {
225
229
}
226
230
227
231
fn outside_if_and_while_expr ( ) {
228
- & let 0 = 0 ; //~ ERROR `let` expressions are not supported here
232
+ & let 0 = 0 ;
233
+ //~^ ERROR `let` expressions are not supported here
234
+ //~| ERROR expected expression, found `let` statement
229
235
230
- !let 0 = 0 ; //~ ERROR `let` expressions are not supported here
231
- * let 0 = 0 ; //~ ERROR `let` expressions are not supported here
232
- //~^ ERROR type `bool` cannot be dereferenced
233
- -let 0 = 0 ; //~ ERROR `let` expressions are not supported here
234
- //~^ ERROR cannot apply unary operator `-` to type `bool`
236
+ !let 0 = 0 ;
237
+ //~^ ERROR `let` expressions are not supported here
238
+ //~| ERROR expected expression, found `let` statement
239
+ * let 0 = 0 ;
240
+ //~^ ERROR `let` expressions are not supported here
241
+ //~| ERROR type `bool` cannot be dereferenced
242
+ //~| ERROR expected expression, found `let` statement
243
+ -let 0 = 0 ;
244
+ //~^ ERROR `let` expressions are not supported here
245
+ //~| ERROR cannot apply unary operator `-` to type `bool`
246
+ //~| ERROR expected expression, found `let` statement
235
247
236
248
fn _check_try_binds_tighter ( ) -> Result < ( ) , ( ) > {
237
249
let 0 = 0 ?;
238
250
//~^ ERROR the `?` operator can only be applied to values that implement `Try`
239
251
Ok ( ( ) )
240
252
}
241
- ( let 0 = 0 ) ?; //~ ERROR `let` expressions are not supported here
242
- //~^ ERROR the `?` operator can only be used in a function that returns `Result`
253
+ ( let 0 = 0 ) ?;
254
+ //~^ ERROR `let` expressions are not supported here
255
+ //~| ERROR the `?` operator can only be used in a function that returns `Result`
243
256
//~| ERROR the `?` operator can only be applied to values that implement `Try`
257
+ //~| ERROR expected expression, found `let` statement
244
258
245
- true || let 0 = 0 ; //~ ERROR `let` expressions are not supported here
246
- ( true || let 0 = 0 ) ; //~ ERROR `let` expressions are not supported here
247
- true && ( true || let 0 = 0 ) ; //~ ERROR `let` expressions are not supported here
259
+ true || let 0 = 0 ;
260
+ //~^ ERROR `let` expressions are not supported here
261
+ //~| ERROR expected expression, found `let` statement
262
+ ( true || let 0 = 0 ) ;
263
+ //~^ ERROR `let` expressions are not supported here
264
+ //~| ERROR expected expression, found `let` statement
265
+ true && ( true || let 0 = 0 ) ;
266
+ //~^ ERROR `let` expressions are not supported here
267
+ //~| ERROR expected expression, found `let` statement
248
268
249
269
let mut x = true ;
250
- x = let 0 = 0 ; //~ ERROR `let` expressions are not supported here
270
+ x = let 0 = 0 ;
271
+ //~^ ERROR `let` expressions are not supported here
272
+ //~| ERROR expected expression, found `let` statement
251
273
252
- true ..( let 0 = 0 ) ; //~ ERROR `let` expressions are not supported here
253
- ..( let 0 = 0 ) ; //~ ERROR `let` expressions are not supported here
254
- ( let 0 = 0 ) ..; //~ ERROR `let` expressions are not supported here
274
+ true ..( let 0 = 0 ) ;
275
+ //~^ ERROR `let` expressions are not supported here
276
+ //~| ERROR expected expression, found `let` statement
277
+ ..( let 0 = 0 ) ;
278
+ //~^ ERROR `let` expressions are not supported here
279
+ //~| ERROR expected expression, found `let` statement
280
+ ( let 0 = 0 ) ..;
281
+ //~^ ERROR `let` expressions are not supported here
282
+ //~| ERROR expected expression, found `let` statement
255
283
256
284
( let Range { start : _, end : _ } = true ..true || false ) ;
257
285
//~^ ERROR `let` expressions are not supported here
258
286
//~| ERROR mismatched types
287
+ //~| ERROR expected expression, found `let` statement
259
288
260
289
( let true = let true = true ) ;
261
290
//~^ ERROR `let` expressions are not supported here
291
+ //~| ERROR expected expression, found `let` statement
292
+ //~| ERROR expected expression, found `let` statement
293
+
294
+ {
295
+ #[ cfg( FALSE ) ]
296
+ let x = true && let y = 1 ;
297
+ //~^ ERROR expected expression, found `let` statement
298
+ }
299
+
300
+ #[ cfg( FALSE ) ]
301
+ {
302
+ [ 1 , 2 , 3 ] [ let _ = ( ) ]
303
+ //~^ ERROR expected expression, found `let` statement
304
+ }
262
305
263
306
// Check function tail position.
264
307
& let 0 = 0
265
308
//~^ ERROR `let` expressions are not supported here
266
309
//~| ERROR mismatched types
310
+ //~| ERROR expected expression, found `let` statement
267
311
}
268
312
269
313
// Let's make sure that `let` inside const generic arguments are considered.
@@ -335,4 +379,14 @@ fn with_parenthesis() {
335
379
let fun = || true ;
336
380
if let true = ( true && fun ( ) ) && ( true ) {
337
381
}
382
+
383
+ #[ cfg( FALSE ) ]
384
+ let x = ( true && let y = 1 ) ;
385
+ //~^ ERROR expected expression, found `let` statement
386
+
387
+ #[ cfg( FALSE ) ]
388
+ {
389
+ ( [ 1 , 2 , 3 ] [ let _ = ( ) ] )
390
+ //~^ ERROR expected expression, found `let` statement
391
+ }
338
392
}
0 commit comments