]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lint/dead-code/issue-85071.rs
Auto merge of #106349 - LeSeulArtichaut:dyn-star-tracking-issue, r=jackh726
[rust.git] / src / test / ui / lint / dead-code / issue-85071.rs
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 }