about summary refs log tree commit diff
path: root/tests/coverage-map/status-quo/dead_code.rs
diff options
context:
space:
mode:
authorZalathar <Zalathar@users.noreply.github.com>2023-08-14 21:29:41 +1000
committerZalathar <Zalathar@users.noreply.github.com>2023-09-05 11:55:34 +1000
commit3141177995f52fc3cbb64d66cf0a98ea0f754fca (patch)
tree59c3eb121dbfee7c2793e0b85037a05e1198d74d /tests/coverage-map/status-quo/dead_code.rs
parent004db4728bc6ccc62416f93ba6473b144def7fe8 (diff)
downloadrust-3141177995f52fc3cbb64d66cf0a98ea0f754fca.tar.gz
rust-3141177995f52fc3cbb64d66cf0a98ea0f754fca.zip
Copy most of `tests/run-coverage` into `tests/coverage-map/status-quo`
The output of these tests is too complicated to comfortably verify by hand, but
we can still use them to observe changes to the underlying mappings produced by
codegen/LLVM.

If these tests fail due to non-coverage changes (e.g. in HIR-to-MIR lowering or
MIR optimizations), it should usually be OK to just `--bless` them, as long as
the `run-coverage` test suite still works.
Diffstat (limited to 'tests/coverage-map/status-quo/dead_code.rs')
-rw-r--r--tests/coverage-map/status-quo/dead_code.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/coverage-map/status-quo/dead_code.rs b/tests/coverage-map/status-quo/dead_code.rs
new file mode 100644
index 00000000000..3492712a6f9
--- /dev/null
+++ b/tests/coverage-map/status-quo/dead_code.rs
@@ -0,0 +1,37 @@
+#![allow(dead_code, unused_assignments, unused_variables)]
+
+pub fn unused_pub_fn_not_in_library() {
+    // Initialize test constants in a way that cannot be determined at compile time, to ensure
+    // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
+    // dependent conditions.
+    let is_true = std::env::args().len() == 1;
+
+    let mut countdown = 0;
+    if is_true {
+        countdown = 10;
+    }
+}
+
+fn unused_fn() {
+    // Initialize test constants in a way that cannot be determined at compile time, to ensure
+    // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
+    // dependent conditions.
+    let is_true = std::env::args().len() == 1;
+
+    let mut countdown = 0;
+    if is_true {
+        countdown = 10;
+    }
+}
+
+fn main() {
+    // Initialize test constants in a way that cannot be determined at compile time, to ensure
+    // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
+    // dependent conditions.
+    let is_true = std::env::args().len() == 1;
+
+    let mut countdown = 0;
+    if is_true {
+        countdown = 10;
+    }
+}