Skip to content

Commit 72b721f

Browse files
committed
Resolve all warnings in run-coverage tests
When one of these tests fails, any compiler warnings will be printed to the console, which makes it harder to track down the actual reason for failure. (The outstanding warnings were found by temporarily adding `-Dwarnings` to the compiler arguments for `RunCoverage` in `src/tools/compiletest/src/runtest.rs`.)
1 parent 9334ec9 commit 72b721f

20 files changed

+22
-20
lines changed

tests/run-coverage/async2.coverage

-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
LL| |// compile-flags: --edition=2018
22
LL| |
3-
LL| |use core::{
4-
LL| | future::Future,
5-
LL| | marker::Send,
6-
LL| | pin::Pin,
7-
LL| |};
8-
LL| |
93
LL| 1|fn non_async_func() {
104
LL| 1| println!("non_async_func was covered");
115
LL| 1| let b = true;

tests/run-coverage/async2.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
// compile-flags: --edition=2018
22

3-
use core::{
4-
future::Future,
5-
marker::Send,
6-
pin::Pin,
7-
};
8-
93
fn non_async_func() {
104
println!("non_async_func was covered");
115
let b = true;
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[allow(dead_code)]
12
pub fn never_called_function() {
23
println!("I am never called");
34
}

tests/run-coverage/auxiliary/used_crate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub fn unused_function() {
4242
}
4343
}
4444

45+
#[allow(dead_code)]
4546
fn unused_private_function() {
4647
let is_true = std::env::args().len() == 1;
4748
let mut countdown = 2;

tests/run-coverage/auxiliary/used_inline_crate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ pub fn unused_function() {
7171
}
7272

7373
#[inline(always)]
74+
#[allow(dead_code)]
7475
fn unused_private_function() {
7576
let is_true = std::env::args().len() == 1;
7677
let mut countdown = 2;

tests/run-coverage/closure_macro_async.coverage

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
LL| |
4343
LL| |#[no_coverage]
4444
LL| |fn main() {
45-
LL| | executor::block_on(test());
45+
LL| | executor::block_on(test()).unwrap();
4646
LL| |}
4747
LL| |
4848
LL| |mod executor {

tests/run-coverage/closure_macro_async.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub async fn test() -> Result<(), String> {
4141

4242
#[no_coverage]
4343
fn main() {
44-
executor::block_on(test());
44+
executor::block_on(test()).unwrap();
4545
}
4646

4747
mod executor {

tests/run-coverage/dead_code.coverage

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
LL| |#![allow(unused_assignments, unused_variables)]
1+
LL| |#![allow(dead_code, unused_assignments, unused_variables)]
22
LL| |
33
LL| 0|pub fn unused_pub_fn_not_in_library() {
44
LL| 0| // Initialize test constants in a way that cannot be determined at compile time, to ensure

tests/run-coverage/dead_code.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(unused_assignments, unused_variables)]
1+
#![allow(dead_code, unused_assignments, unused_variables)]
22

33
pub fn unused_pub_fn_not_in_library() {
44
// Initialize test constants in a way that cannot be determined at compile time, to ensure

tests/run-coverage/issue-93054.coverage

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
LL| |#![allow(dead_code, unreachable_code)]
2+
LL| |
13
LL| |// Regression test for #93054: Functions using uninhabited types often only have a single,
24
LL| |// unreachable basic block which doesn't get instrumented. This should not cause llvm-cov to fail.
35
LL| |// Since these kinds functions can't be invoked anyway, it's ok to not have coverage data for them.

tests/run-coverage/issue-93054.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(dead_code, unreachable_code)]
2+
13
// Regression test for #93054: Functions using uninhabited types often only have a single,
24
// unreachable basic block which doesn't get instrumented. This should not cause llvm-cov to fail.
35
// Since these kinds functions can't be invoked anyway, it's ok to not have coverage data for them.

tests/run-coverage/match_or_pattern.coverage

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
LL| |#![feature(or_patterns)]
2-
LL| |
31
LL| 1|fn main() {
42
LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure
53
LL| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from

tests/run-coverage/match_or_pattern.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(or_patterns)]
2-
31
fn main() {
42
// Initialize test constants in a way that cannot be determined at compile time, to ensure
53
// rustc and LLVM cannot optimize out statements (or coverage counters) downstream from

tests/run-coverage/no_cov_crate.coverage

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
LL| |}
1313
LL| |
1414
LL| |#[no_coverage]
15+
LL| |#[allow(dead_code)]
1516
LL| |fn do_not_add_coverage_not_called() {
1617
LL| | println!("not called and not covered");
1718
LL| |}
@@ -24,6 +25,7 @@
2425
LL| 1| println!("called and covered");
2526
LL| 1|}
2627
LL| |
28+
LL| |#[allow(dead_code)]
2729
LL| 0|fn add_coverage_not_called() {
2830
LL| 0| println!("not called but covered");
2931
LL| 0|}

tests/run-coverage/no_cov_crate.rs

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ fn do_not_add_coverage_2() {
1212
}
1313

1414
#[no_coverage]
15+
#[allow(dead_code)]
1516
fn do_not_add_coverage_not_called() {
1617
println!("not called and not covered");
1718
}
@@ -24,6 +25,7 @@ fn add_coverage_2() {
2425
println!("called and covered");
2526
}
2627

28+
#[allow(dead_code)]
2729
fn add_coverage_not_called() {
2830
println!("not called but covered");
2931
}

tests/run-coverage/unused.coverage

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
LL| |#![allow(dead_code, unused_assignments, unused_must_use, unused_variables)]
2+
LL| |
13
LL| 2|fn foo<T>(x: T) {
24
LL| 2| let mut i = 0;
35
LL| 22| while i < 10 {

tests/run-coverage/unused.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(dead_code, unused_assignments, unused_must_use, unused_variables)]
2+
13
fn foo<T>(x: T) {
24
let mut i = 0;
35
while i < 10 {

tests/run-coverage/unused_mod.coverage

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
$DIR/auxiliary/unused_mod_helper.rs:
2+
LL| |#[allow(dead_code)]
23
LL| 0|pub fn never_called_function() {
34
LL| 0| println!("I am never called");
45
LL| 0|}

tests/run-coverage/uses_crate.coverage

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ $DIR/auxiliary/used_crate.rs:
9090
LL| 0| }
9191
LL| 0|}
9292
LL| |
93+
LL| |#[allow(dead_code)]
9394
LL| 0|fn unused_private_function() {
9495
LL| 0| let is_true = std::env::args().len() == 1;
9596
LL| 0| let mut countdown = 2;

tests/run-coverage/uses_inline_crate.coverage

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ $DIR/auxiliary/used_inline_crate.rs:
120120
LL| 0|}
121121
LL| |
122122
LL| |#[inline(always)]
123+
LL| |#[allow(dead_code)]
123124
LL| 0|fn unused_private_function() {
124125
LL| 0| let is_true = std::env::args().len() == 1;
125126
LL| 0| let mut countdown = 2;

0 commit comments

Comments
 (0)