diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2023-08-17 11:24:56 +1000 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2023-08-26 14:35:34 +1000 |
| commit | 72b721f48e3695f25a0935ad535e75e6777d829b (patch) | |
| tree | d9035f73872bfb90c94385098bb79f48c869b9aa | |
| parent | 9334ec93541fd6963a3bfa2d2d09e3e33ac93131 (diff) | |
| download | rust-72b721f48e3695f25a0935ad535e75e6777d829b.tar.gz rust-72b721f48e3695f25a0935ad535e75e6777d829b.zip | |
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`.)
20 files changed, 22 insertions, 20 deletions
diff --git a/tests/run-coverage/async2.coverage b/tests/run-coverage/async2.coverage index 7e0139ae036..db17b557167 100644 --- a/tests/run-coverage/async2.coverage +++ b/tests/run-coverage/async2.coverage @@ -1,11 +1,5 @@ LL| |// compile-flags: --edition=2018 LL| | - LL| |use core::{ - LL| | future::Future, - LL| | marker::Send, - LL| | pin::Pin, - LL| |}; - LL| | LL| 1|fn non_async_func() { LL| 1| println!("non_async_func was covered"); LL| 1| let b = true; diff --git a/tests/run-coverage/async2.rs b/tests/run-coverage/async2.rs index 959d48ce9db..21f4e65de30 100644 --- a/tests/run-coverage/async2.rs +++ b/tests/run-coverage/async2.rs @@ -1,11 +1,5 @@ // compile-flags: --edition=2018 -use core::{ - future::Future, - marker::Send, - pin::Pin, -}; - fn non_async_func() { println!("non_async_func was covered"); let b = true; diff --git a/tests/run-coverage/auxiliary/unused_mod_helper.rs b/tests/run-coverage/auxiliary/unused_mod_helper.rs index ae1cc1531ed..88c5dac65cb 100644 --- a/tests/run-coverage/auxiliary/unused_mod_helper.rs +++ b/tests/run-coverage/auxiliary/unused_mod_helper.rs @@ -1,3 +1,4 @@ +#[allow(dead_code)] pub fn never_called_function() { println!("I am never called"); } diff --git a/tests/run-coverage/auxiliary/used_crate.rs b/tests/run-coverage/auxiliary/used_crate.rs index 16592d48dda..2107bb59c02 100644 --- a/tests/run-coverage/auxiliary/used_crate.rs +++ b/tests/run-coverage/auxiliary/used_crate.rs @@ -42,6 +42,7 @@ pub fn unused_function() { } } +#[allow(dead_code)] fn unused_private_function() { let is_true = std::env::args().len() == 1; let mut countdown = 2; diff --git a/tests/run-coverage/auxiliary/used_inline_crate.rs b/tests/run-coverage/auxiliary/used_inline_crate.rs index 8b8e9d5483f..20882fd4df0 100644 --- a/tests/run-coverage/auxiliary/used_inline_crate.rs +++ b/tests/run-coverage/auxiliary/used_inline_crate.rs @@ -71,6 +71,7 @@ pub fn unused_function() { } #[inline(always)] +#[allow(dead_code)] fn unused_private_function() { let is_true = std::env::args().len() == 1; let mut countdown = 2; diff --git a/tests/run-coverage/closure_macro_async.coverage b/tests/run-coverage/closure_macro_async.coverage index 0e4365fc797..4cd40384780 100644 --- a/tests/run-coverage/closure_macro_async.coverage +++ b/tests/run-coverage/closure_macro_async.coverage @@ -42,7 +42,7 @@ LL| | LL| |#[no_coverage] LL| |fn main() { - LL| | executor::block_on(test()); + LL| | executor::block_on(test()).unwrap(); LL| |} LL| | LL| |mod executor { diff --git a/tests/run-coverage/closure_macro_async.rs b/tests/run-coverage/closure_macro_async.rs index e3e89e9c8b3..a90827572bb 100644 --- a/tests/run-coverage/closure_macro_async.rs +++ b/tests/run-coverage/closure_macro_async.rs @@ -41,7 +41,7 @@ pub async fn test() -> Result<(), String> { #[no_coverage] fn main() { - executor::block_on(test()); + executor::block_on(test()).unwrap(); } mod executor { diff --git a/tests/run-coverage/dead_code.coverage b/tests/run-coverage/dead_code.coverage index 5074d8b3c37..c4ee9f23f08 100644 --- a/tests/run-coverage/dead_code.coverage +++ b/tests/run-coverage/dead_code.coverage @@ -1,4 +1,4 @@ - LL| |#![allow(unused_assignments, unused_variables)] + LL| |#![allow(dead_code, unused_assignments, unused_variables)] LL| | LL| 0|pub fn unused_pub_fn_not_in_library() { LL| 0| // Initialize test constants in a way that cannot be determined at compile time, to ensure diff --git a/tests/run-coverage/dead_code.rs b/tests/run-coverage/dead_code.rs index a1285df0ec6..3492712a6f9 100644 --- a/tests/run-coverage/dead_code.rs +++ b/tests/run-coverage/dead_code.rs @@ -1,4 +1,4 @@ -#![allow(unused_assignments, unused_variables)] +#![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 diff --git a/tests/run-coverage/issue-93054.coverage b/tests/run-coverage/issue-93054.coverage index 074e6b9835a..224c01d9a8b 100644 --- a/tests/run-coverage/issue-93054.coverage +++ b/tests/run-coverage/issue-93054.coverage @@ -1,3 +1,5 @@ + LL| |#![allow(dead_code, unreachable_code)] + LL| | LL| |// Regression test for #93054: Functions using uninhabited types often only have a single, LL| |// unreachable basic block which doesn't get instrumented. This should not cause llvm-cov to fail. LL| |// Since these kinds functions can't be invoked anyway, it's ok to not have coverage data for them. diff --git a/tests/run-coverage/issue-93054.rs b/tests/run-coverage/issue-93054.rs index c160b3db03f..9f695b7fd11 100644 --- a/tests/run-coverage/issue-93054.rs +++ b/tests/run-coverage/issue-93054.rs @@ -1,3 +1,5 @@ +#![allow(dead_code, unreachable_code)] + // Regression test for #93054: Functions using uninhabited types often only have a single, // unreachable basic block which doesn't get instrumented. This should not cause llvm-cov to fail. // Since these kinds functions can't be invoked anyway, it's ok to not have coverage data for them. diff --git a/tests/run-coverage/match_or_pattern.coverage b/tests/run-coverage/match_or_pattern.coverage index 0b5a2c03dd3..94c7967215c 100644 --- a/tests/run-coverage/match_or_pattern.coverage +++ b/tests/run-coverage/match_or_pattern.coverage @@ -1,5 +1,3 @@ - LL| |#![feature(or_patterns)] - LL| | LL| 1|fn main() { LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure LL| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from diff --git a/tests/run-coverage/match_or_pattern.rs b/tests/run-coverage/match_or_pattern.rs index 4c6a8a9b703..ab7aee51d1b 100644 --- a/tests/run-coverage/match_or_pattern.rs +++ b/tests/run-coverage/match_or_pattern.rs @@ -1,5 +1,3 @@ -#![feature(or_patterns)] - 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 diff --git a/tests/run-coverage/no_cov_crate.coverage b/tests/run-coverage/no_cov_crate.coverage index c34dbde888a..73f6fbd0c2b 100644 --- a/tests/run-coverage/no_cov_crate.coverage +++ b/tests/run-coverage/no_cov_crate.coverage @@ -12,6 +12,7 @@ LL| |} LL| | LL| |#[no_coverage] + LL| |#[allow(dead_code)] LL| |fn do_not_add_coverage_not_called() { LL| | println!("not called and not covered"); LL| |} @@ -24,6 +25,7 @@ LL| 1| println!("called and covered"); LL| 1|} LL| | + LL| |#[allow(dead_code)] LL| 0|fn add_coverage_not_called() { LL| 0| println!("not called but covered"); LL| 0|} diff --git a/tests/run-coverage/no_cov_crate.rs b/tests/run-coverage/no_cov_crate.rs index 0bfbdda2cab..5b748aeefb7 100644 --- a/tests/run-coverage/no_cov_crate.rs +++ b/tests/run-coverage/no_cov_crate.rs @@ -12,6 +12,7 @@ fn do_not_add_coverage_2() { } #[no_coverage] +#[allow(dead_code)] fn do_not_add_coverage_not_called() { println!("not called and not covered"); } @@ -24,6 +25,7 @@ fn add_coverage_2() { println!("called and covered"); } +#[allow(dead_code)] fn add_coverage_not_called() { println!("not called but covered"); } diff --git a/tests/run-coverage/unused.coverage b/tests/run-coverage/unused.coverage index ba25e34bf86..056ffeb021a 100644 --- a/tests/run-coverage/unused.coverage +++ b/tests/run-coverage/unused.coverage @@ -1,3 +1,5 @@ + LL| |#![allow(dead_code, unused_assignments, unused_must_use, unused_variables)] + LL| | LL| 2|fn foo<T>(x: T) { LL| 2| let mut i = 0; LL| 22| while i < 10 { diff --git a/tests/run-coverage/unused.rs b/tests/run-coverage/unused.rs index fb6113eb01c..d985af13547 100644 --- a/tests/run-coverage/unused.rs +++ b/tests/run-coverage/unused.rs @@ -1,3 +1,5 @@ +#![allow(dead_code, unused_assignments, unused_must_use, unused_variables)] + fn foo<T>(x: T) { let mut i = 0; while i < 10 { diff --git a/tests/run-coverage/unused_mod.coverage b/tests/run-coverage/unused_mod.coverage index 558dfaa5cff..a8fa24ac6a7 100644 --- a/tests/run-coverage/unused_mod.coverage +++ b/tests/run-coverage/unused_mod.coverage @@ -1,4 +1,5 @@ $DIR/auxiliary/unused_mod_helper.rs: + LL| |#[allow(dead_code)] LL| 0|pub fn never_called_function() { LL| 0| println!("I am never called"); LL| 0|} diff --git a/tests/run-coverage/uses_crate.coverage b/tests/run-coverage/uses_crate.coverage index 9da096dbd50..2cee358665a 100644 --- a/tests/run-coverage/uses_crate.coverage +++ b/tests/run-coverage/uses_crate.coverage @@ -90,6 +90,7 @@ $DIR/auxiliary/used_crate.rs: LL| 0| } LL| 0|} LL| | + LL| |#[allow(dead_code)] LL| 0|fn unused_private_function() { LL| 0| let is_true = std::env::args().len() == 1; LL| 0| let mut countdown = 2; diff --git a/tests/run-coverage/uses_inline_crate.coverage b/tests/run-coverage/uses_inline_crate.coverage index 48493e2079c..7d909c78647 100644 --- a/tests/run-coverage/uses_inline_crate.coverage +++ b/tests/run-coverage/uses_inline_crate.coverage @@ -120,6 +120,7 @@ $DIR/auxiliary/used_inline_crate.rs: LL| 0|} LL| | LL| |#[inline(always)] + LL| |#[allow(dead_code)] LL| 0|fn unused_private_function() { LL| 0| let is_true = std::env::args().len() == 1; LL| 0| let mut countdown = 2; |
