Open GrigorenkoPV opened 1 year ago
Strangely,
pub fn main() {
let a = if true {
((), panic!()) // not `loop {}`, `todo!()`, or anything else
} else {
((), ())
};
}
compiles on edition <= 2018. Also, this issue is not present on Rust 1.17 (Godbolt).
@rustbot label regression-from-stable-to-stable
WG-prioritization assigning priority (Zulip discussion).
@rustbot label -I-prioritize +P-low +T-compiler
@rustbot label +F-never_type
Playground
I tried this code:
I expected to see this happen:
Code compiles, runs, and panics.
a
has type((), ())
.Instead, this happened:
The following changes have no effect:
let a =
.true
to some runtime-only condition.if
-else
withmatch
.todo!()
and()
inside of the tuple.todo!()
withloop{}
orstd::process::exit(0)
.todo!()
with a call to a function returningstd::convert::Infallible
(though this makes the warning about the unreachable code go away).u8
or any other "normal" type instead of()
.The following changes make the error go away.
*
*
*
*
Meta
rustc --version --verbose
:Same on nightly and beta.
Must be related to #35121.