]> git.proxmox.com Git - rustc.git/blame - src/test/ui/lint/dead-code/issue-85071.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / lint / dead-code / issue-85071.rs
CommitLineData
94222f64
XL
1// Checks that an unreachable code warning is emitted when an expression is
2// preceded by an expression with an uninhabited type. Previously, the
3// variable liveness analysis was "smarter" than the reachability analysis
4// in this regard, which led to confusing "unused variable" warnings
5// without an accompanying explanatory "unreachable expression" warning.
6
7// check-pass
8
9#![warn(unused_variables,unreachable_code)]
10
11enum Foo {}
12fn f() -> Foo {todo!()}
13
14fn main() {
15 let x = f();
16 //~^ WARNING: unused variable: `x`
17 let _ = x;
18 //~^ WARNING: unreachable expression
19}