Closed as not planned
Description
Consider this code:
#![feature(never_type, try_blocks)]
fn main() {
let _: Result<!, ()> = try {
();
return
};
}
It compiles.
Rustfmt adds a semicolon here:
#![feature(never_type, try_blocks)]
fn main() {
let _: Result<!, ()> = try {
();
return;
};
}
This causes a compilation error:
Compiling playground v0.0.1 (/playground)
error[E0271]: type mismatch resolving `<Result<!, ()> as Try>::Output == ()`
--> src/main.rs:7:5
|
7 | };
| ^ expected `()`, found `!`
|
= note: expected unit type `()`
found type `!`
For more information about this error, try `rustc --explain E0271`.
error: could not compile `playground` (bin "playground") due to 1 previous error
I'm not sure if rustfmt shouldn't add a semicolon here or if rustc should accept a semicolon.
Meta
Nightly channel
Build using the Nightly version: 1.88.0-nightly
(2025-04-26 10fa3c449f6b1613b352)