Skip to content

Commit 0e89f55

Browse files
committed
E0269: add suggestion to check for trailing semicolons
In situations where the value of the last expression must be inferred, rustc will not emit the "you might need to remove the semicolon" warning, so at least note this in the extended description. Fixes: rust-lang#30497
1 parent 2a815a2 commit 0e89f55

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/librustc/diagnostics.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,17 @@ fn foo(x: u8) -> u8 {
635635
```
636636
637637
It is advisable to find out what the unhandled cases are and check for them,
638-
returning an appropriate value or panicking if necessary.
638+
returning an appropriate value or panicking if necessary. Check if you need
639+
to remove a semicolon from the last expression, like in this case:
640+
641+
```ignore
642+
fn foo(x: u8) -> u8 {
643+
inner(2*x + 1);
644+
}
645+
```
646+
647+
The semicolon discards the return value of `inner`, instead of returning
648+
it from `foo`.
639649
"##,
640650

641651
E0270: r##"

0 commit comments

Comments
 (0)