summaryrefslogtreecommitdiffstats
path: root/src/test/ui/lint/dead-code/issue-85071.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/lint/dead-code/issue-85071.rs')
-rw-r--r--src/test/ui/lint/dead-code/issue-85071.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test/ui/lint/dead-code/issue-85071.rs b/src/test/ui/lint/dead-code/issue-85071.rs
new file mode 100644
index 000000000..d6969321c
--- /dev/null
+++ b/src/test/ui/lint/dead-code/issue-85071.rs
@@ -0,0 +1,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
+}