]>
Commit | Line | Data |
---|---|---|
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 | ||
11 | enum Foo {} | |
12 | fn f() -> Foo {todo!()} | |
13 | ||
14 | fn main() { | |
15 | let x = f(); | |
16 | //~^ WARNING: unused variable: `x` | |
17 | let _ = x; | |
18 | //~^ WARNING: unreachable expression | |
19 | } |