Skip to content

Commit 68c29e0

Browse files
committed
Rollup merge of rust-lang#33324 - birkenfeld:issue-30497, r=GuillaumeGomez
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
2 parents c4d950d + 0e89f55 commit 68c29e0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/librustc/diagnostics.rs

+11-1
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)