Open
Description
The following snippet generates an "unreachable definition" warning at let _x = 1
(godbolt at 1.69):
fn infallible() -> std::convert::Infallible {
loop {}
}
fn main() {
if false {
infallible();
}
let _x = 1;
}
Full output:
warning: unreachable definition
--> <source>:10:9
|
7 | infallible();
| ------------ any code following this expression is unreachable
...
10 | let _x = 123;
| ^^ unreachable definition
|
note: this expression has type `Infallible`, which is uninhabited
--> <source>:7:9
|
7 | infallible();
| ^^^^^^^^^^^^
= note: `#[warn(unreachable_code)]` on by default
Runtime behaviour is as expected (it exits), so this warning seems wrong.
This occurs in rustc 1.71.0-nightly (c4190f2 2023-05-07) all the way back to rustc 1.56.
A similar issue (with an expression instead of a definition) has been brought up in #89779. However, that specific case disappeared in rustc 1.60.