@@ -337,15 +337,38 @@ When you run this program, the error you’ll get looks like this:
337
337
``` text
338
338
$ cargo run
339
339
Compiling functions v0.1.0 (file:///projects/functions)
340
+ error[E0658]: `let` expressions in this position are experimental
341
+ --> src/main.rs:2:14
342
+ |
343
+ 2 | let x = (let y = 6);
344
+ | ^^^^^^^^^
345
+ |
346
+ = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
347
+
340
348
error: expected expression, found statement (`let`)
341
349
(エラー: 式を予期しましたが、文が見つかりました (`let`))
342
350
--> src/main.rs:2:14
343
351
|
344
352
2 | let x = (let y = 6);
345
- | ^^^
353
+ | ^^^^^^^^^
346
354
|
347
355
= note: variable declaration using `let` is a statement
348
356
(注釈: `let`を使う変数宣言は、文です)
357
+
358
+ warning: unnecessary parentheses around assigned value
359
+ --> src/main.rs:2:13
360
+ |
361
+ 2 | let x = (let y = 6);
362
+ | ^^^^^^^^^^^ help: remove these parentheses
363
+ |
364
+ = note: `#[warn(unused_parens)]` on by default
365
+
366
+ error: aborting due to 2 previous errors; 1 warning emitted
367
+
368
+ For more information about this error, try `rustc --explain E0658`.
369
+ error: could not compile `functions`
370
+
371
+ To learn more, run the command again with --verbose.
349
372
```
350
373
351
374
<!--
@@ -563,20 +586,26 @@ Running this code produces an error, as follows:
563
586
このコードを実行すると、以下のようにエラーが出ます:
564
587
565
588
``` text
589
+ $ cargo run
590
+ Compiling functions v0.1.0 (file:///projects/functions)
566
591
error[E0308]: mismatched types
567
592
(型が合いません)
568
- --> src/main.rs:7:28
569
- |
570
- 7 | fn plus_one(x: i32) -> i32 {
571
- | ____________________________^
572
- 8 | | x + 1;
573
- | | - help: consider removing this semicolon
574
- 9 | | }
575
- | |_^ expected i32, found ()
576
- | (i32を予期したのに、()型が見つかりました)
593
+
594
+ --> src/main.rs:7:24
577
595
|
578
- = note: expected type `i32`
579
- found type `()`
596
+ 7 | fn plus_one(x: i32) -> i32 {
597
+ | -------- ^^^ expected `i32`, found `()`
598
+ | |
599
+ | implicitly returns `()` as its body has no tail or `return` expression
600
+ 8 | x + 1;
601
+ | - help: consider removing this semicolon
602
+
603
+ error: aborting due to previous error
604
+
605
+ For more information about this error, try `rustc --explain E0308`.
606
+ error: could not compile `functions`
607
+
608
+ To learn more, run the command again with --verbose.
580
609
```
581
610
582
611
<!--
0 commit comments