summaryrefslogtreecommitdiffstats
path: root/src/test/ui/lint/dead-code/issue-85071.rs
blob: d6969321cad4b5e7a1a37e2ee8dfdd787b4cd48b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Checks that an unreachable code warning is emitted when an expression is
// preceded by an expression with an uninhabited type. Previously, the
// variable liveness analysis was "smarter" than the reachability analysis
// in this regard, which led to confusing "unused variable" warnings
// without an accompanying explanatory "unreachable expression" warning.

// check-pass

#![warn(unused_variables,unreachable_code)]

enum Foo {}
fn f() -> Foo {todo!()}

fn main() {
    let x = f();
    //~^ WARNING: unused variable: `x`
    let _ = x;
    //~^ WARNING: unreachable expression
}