From 72b721f48e3695f25a0935ad535e75e6777d829b Mon Sep 17 00:00:00 2001 From: Zalathar Date: Thu, 17 Aug 2023 11:24:56 +1000 Subject: [PATCH 1/3] 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`.) --- tests/run-coverage/async2.coverage | 6 ------ tests/run-coverage/async2.rs | 6 ------ tests/run-coverage/auxiliary/unused_mod_helper.rs | 1 + tests/run-coverage/auxiliary/used_crate.rs | 1 + tests/run-coverage/auxiliary/used_inline_crate.rs | 1 + tests/run-coverage/closure_macro_async.coverage | 2 +- tests/run-coverage/closure_macro_async.rs | 2 +- tests/run-coverage/dead_code.coverage | 2 +- tests/run-coverage/dead_code.rs | 2 +- tests/run-coverage/issue-93054.coverage | 2 ++ tests/run-coverage/issue-93054.rs | 2 ++ tests/run-coverage/match_or_pattern.coverage | 2 -- tests/run-coverage/match_or_pattern.rs | 2 -- tests/run-coverage/no_cov_crate.coverage | 2 ++ tests/run-coverage/no_cov_crate.rs | 2 ++ tests/run-coverage/unused.coverage | 2 ++ tests/run-coverage/unused.rs | 2 ++ tests/run-coverage/unused_mod.coverage | 1 + tests/run-coverage/uses_crate.coverage | 1 + tests/run-coverage/uses_inline_crate.coverage | 1 + 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(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(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; From 4da38c31d21347fe7800c4263cb34a8c9e62d0fb Mon Sep 17 00:00:00 2001 From: Zalathar Date: Thu, 17 Aug 2023 11:32:33 +1000 Subject: [PATCH 2/3] Tidy up some awkwardly-placed comments in tests Prior to #114875, these tests were very sensitive to lines being added/removed, so the migration to `run-coverage` in #112300 tried hard to avoid disturbing the existing line numbers. That resulted in some awkward reshuffling when certain comments/directives needed to be added or moved. Now that we don't have to worry about preserving line numbers, we can rearrange those comments into a more conventional layout. --- tests/run-coverage-rustdoc/doctest.coverage | 4 +++- tests/run-coverage-rustdoc/doctest.rs | 4 +++- tests/run-coverage/auxiliary/used_crate.rs | 4 +++- tests/run-coverage/auxiliary/used_inline_crate.rs | 4 ++-- tests/run-coverage/closure.coverage | 7 ++++++- tests/run-coverage/closure.rs | 7 ++++++- tests/run-coverage/issue-85461.coverage | 1 + tests/run-coverage/issue-85461.rs | 1 + tests/run-coverage/uses_crate.coverage | 4 +++- tests/run-coverage/uses_inline_crate.coverage | 4 ++-- 10 files changed, 30 insertions(+), 10 deletions(-) diff --git a/tests/run-coverage-rustdoc/doctest.coverage b/tests/run-coverage-rustdoc/doctest.coverage index 07f1e6b3ee5..5797784f411 100644 --- a/tests/run-coverage-rustdoc/doctest.coverage +++ b/tests/run-coverage-rustdoc/doctest.coverage @@ -10,6 +10,8 @@ $DIR/auxiliary/doctest_crate.rs: LL| 3|} $DIR/doctest.rs: + LL| |// aux-build:doctest_crate.rs + LL| | LL| |//! This test ensures that code from doctests is properly re-mapped. LL| |//! See for more info. LL| |//! @@ -78,7 +80,7 @@ $DIR/doctest.rs: LL| |//! doctest_main() LL| |//! } LL| |//! ``` - LL| |// aux-build:doctest_crate.rs + LL| | LL| |/// doctest attached to fn testing external code: LL| |/// ``` LL| 1|/// extern crate doctest_crate; diff --git a/tests/run-coverage-rustdoc/doctest.rs b/tests/run-coverage-rustdoc/doctest.rs index 251b0c291e9..4006d723ce0 100644 --- a/tests/run-coverage-rustdoc/doctest.rs +++ b/tests/run-coverage-rustdoc/doctest.rs @@ -1,3 +1,5 @@ +// aux-build:doctest_crate.rs + //! This test ensures that code from doctests is properly re-mapped. //! See for more info. //! @@ -63,7 +65,7 @@ //! doctest_main() //! } //! ``` -// aux-build:doctest_crate.rs + /// doctest attached to fn testing external code: /// ``` /// extern crate doctest_crate; diff --git a/tests/run-coverage/auxiliary/used_crate.rs b/tests/run-coverage/auxiliary/used_crate.rs index 2107bb59c02..c086ef21e1a 100644 --- a/tests/run-coverage/auxiliary/used_crate.rs +++ b/tests/run-coverage/auxiliary/used_crate.rs @@ -1,6 +1,8 @@ #![allow(unused_assignments, unused_variables)] +// Verify that coverage works with optimizations: // compile-flags: -C opt-level=3 -use std::fmt::Debug; // ^^ validates coverage now works with optimizations + +use std::fmt::Debug; pub fn used_function() { // Initialize test constants in a way that cannot be determined at compile time, to ensure diff --git a/tests/run-coverage/auxiliary/used_inline_crate.rs b/tests/run-coverage/auxiliary/used_inline_crate.rs index 20882fd4df0..a6651dd8a5e 100644 --- a/tests/run-coverage/auxiliary/used_inline_crate.rs +++ b/tests/run-coverage/auxiliary/used_inline_crate.rs @@ -1,7 +1,7 @@ #![allow(unused_assignments, unused_variables)] - +// Verify that coverage works with optimizations: // compile-flags: -C opt-level=3 -// ^^ validates coverage now works with optimizations + use std::fmt::Debug; pub fn used_function() { diff --git a/tests/run-coverage/closure.coverage b/tests/run-coverage/closure.coverage index 809cf1f4821..211ba4cbe98 100644 --- a/tests/run-coverage/closure.coverage +++ b/tests/run-coverage/closure.coverage @@ -1,6 +1,11 @@ LL| |#![allow(unused_assignments, unused_variables)] LL| |// compile-flags: -C opt-level=2 - LL| 1|fn main() { // ^^ fix described in rustc_middle/mir/mono.rs + LL| | + LL| |// This test used to be sensitive to certain coverage-specific hacks in + LL| |// `rustc_middle/mir/mono.rs`, but those hacks were later cleaned up by + LL| |// . + 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 LL| 1| // dependent conditions. diff --git a/tests/run-coverage/closure.rs b/tests/run-coverage/closure.rs index eb3a1ebff88..7c42458ae1b 100644 --- a/tests/run-coverage/closure.rs +++ b/tests/run-coverage/closure.rs @@ -1,6 +1,11 @@ #![allow(unused_assignments, unused_variables)] // compile-flags: -C opt-level=2 -fn main() { // ^^ fix described in rustc_middle/mir/mono.rs + +// This test used to be sensitive to certain coverage-specific hacks in +// `rustc_middle/mir/mono.rs`, but those hacks were later cleaned up by +// . + +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. diff --git a/tests/run-coverage/issue-85461.coverage b/tests/run-coverage/issue-85461.coverage index f97ab230387..48e76318b0a 100644 --- a/tests/run-coverage/issue-85461.coverage +++ b/tests/run-coverage/issue-85461.coverage @@ -24,6 +24,7 @@ $DIR/auxiliary/inline_always_with_dead_code.rs: $DIR/issue-85461.rs: LL| |// Regression test for #85461: MSVC sometimes fail to link with dead code and #[inline(always)] + LL| | LL| |// aux-build:inline_always_with_dead_code.rs LL| |extern crate inline_always_with_dead_code; LL| | diff --git a/tests/run-coverage/issue-85461.rs b/tests/run-coverage/issue-85461.rs index 6f626b4a65b..9d4c90a827e 100644 --- a/tests/run-coverage/issue-85461.rs +++ b/tests/run-coverage/issue-85461.rs @@ -1,4 +1,5 @@ // Regression test for #85461: MSVC sometimes fail to link with dead code and #[inline(always)] + // aux-build:inline_always_with_dead_code.rs extern crate inline_always_with_dead_code; diff --git a/tests/run-coverage/uses_crate.coverage b/tests/run-coverage/uses_crate.coverage index 2cee358665a..50d92102a10 100644 --- a/tests/run-coverage/uses_crate.coverage +++ b/tests/run-coverage/uses_crate.coverage @@ -1,7 +1,9 @@ $DIR/auxiliary/used_crate.rs: LL| |#![allow(unused_assignments, unused_variables)] + LL| |// Verify that coverage works with optimizations: LL| |// compile-flags: -C opt-level=3 - LL| |use std::fmt::Debug; // ^^ validates coverage now works with optimizations + LL| | + LL| |use std::fmt::Debug; LL| | LL| 1|pub fn used_function() { LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure diff --git a/tests/run-coverage/uses_inline_crate.coverage b/tests/run-coverage/uses_inline_crate.coverage index 7d909c78647..c510b6a6c68 100644 --- a/tests/run-coverage/uses_inline_crate.coverage +++ b/tests/run-coverage/uses_inline_crate.coverage @@ -1,8 +1,8 @@ $DIR/auxiliary/used_inline_crate.rs: LL| |#![allow(unused_assignments, unused_variables)] - LL| | + LL| |// Verify that coverage works with optimizations: LL| |// compile-flags: -C opt-level=3 - LL| |// ^^ validates coverage now works with optimizations + LL| | LL| |use std::fmt::Debug; LL| | LL| 1|pub fn used_function() { From 8d91e71e9a015c864b29725ec9430c5db4325cf4 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Thu, 17 Aug 2023 11:43:10 +1000 Subject: [PATCH 3/3] Various trivial formatting fixes in `run-coverage` tests These changes were made by manually running `rustfmt` on all of the test files, and then manually undoing all cases where the original formatting appeared to have been deliberate. `rustfmt +nightly --config-path=/dev/null --edition=2021 tests/run-coverage*/**/*.rs` --- tests/run-coverage/assert.coverage | 2 +- tests/run-coverage/assert.rs | 2 +- tests/run-coverage/async2.coverage | 6 ------ tests/run-coverage/async2.rs | 6 ------ .../auxiliary/inline_always_with_dead_code.rs | 4 ++-- tests/run-coverage/auxiliary/used_inline_crate.rs | 6 ------ tests/run-coverage/closure.coverage | 2 +- tests/run-coverage/closure.rs | 2 +- tests/run-coverage/closure_macro_async.coverage | 4 ---- tests/run-coverage/closure_macro_async.rs | 4 ---- tests/run-coverage/conditions.coverage | 1 - tests/run-coverage/conditions.rs | 1 - tests/run-coverage/drop_trait.coverage | 2 +- tests/run-coverage/drop_trait.rs | 2 +- tests/run-coverage/generics.coverage | 6 +----- tests/run-coverage/generics.rs | 6 +----- tests/run-coverage/issue-85461.coverage | 4 ++-- tests/run-coverage/issue-93054.coverage | 12 ++++++------ tests/run-coverage/issue-93054.rs | 12 ++++++------ tests/run-coverage/loops_branches.coverage | 3 +-- tests/run-coverage/loops_branches.rs | 3 +-- tests/run-coverage/overflow.coverage | 2 +- tests/run-coverage/overflow.rs | 2 +- tests/run-coverage/try_error_result.coverage | 14 +++++++------- tests/run-coverage/try_error_result.rs | 14 +++++++------- tests/run-coverage/uses_inline_crate.coverage | 6 ------ tests/run-coverage/while_early_ret.coverage | 2 +- tests/run-coverage/while_early_ret.rs | 2 +- tests/run-coverage/yield.coverage | 4 ++-- tests/run-coverage/yield.rs | 4 ++-- 30 files changed, 48 insertions(+), 92 deletions(-) diff --git a/tests/run-coverage/assert.coverage b/tests/run-coverage/assert.coverage index 3c6108e436a..8b997724c4a 100644 --- a/tests/run-coverage/assert.coverage +++ b/tests/run-coverage/assert.coverage @@ -7,7 +7,7 @@ ^1 LL| 3|} LL| | - LL| 1|fn main() -> Result<(),u8> { + LL| 1|fn main() -> Result<(), u8> { LL| 1| let mut countdown = 10; LL| 11| while countdown > 0 { LL| 11| if countdown == 1 { diff --git a/tests/run-coverage/assert.rs b/tests/run-coverage/assert.rs index d32a37e078e..85e6662a6ad 100644 --- a/tests/run-coverage/assert.rs +++ b/tests/run-coverage/assert.rs @@ -6,7 +6,7 @@ fn might_fail_assert(one_plus_one: u32) { assert_eq!(1 + 1, one_plus_one, "the argument was wrong"); } -fn main() -> Result<(),u8> { +fn main() -> Result<(), u8> { let mut countdown = 10; while countdown > 0 { if countdown == 1 { diff --git a/tests/run-coverage/async2.coverage b/tests/run-coverage/async2.coverage index db17b557167..fcb0a3aed64 100644 --- a/tests/run-coverage/async2.coverage +++ b/tests/run-coverage/async2.coverage @@ -9,9 +9,6 @@ ^0 LL| 1|} LL| | - LL| | - LL| | - LL| | LL| 1|async fn async_func() { LL| 1| println!("async_func was covered"); LL| 1| let b = true; @@ -21,9 +18,6 @@ ^0 LL| 1|} LL| | - LL| | - LL| | - LL| | LL| 1|async fn async_func_just_println() { LL| 1| println!("async_func_just_println was covered"); LL| 1|} diff --git a/tests/run-coverage/async2.rs b/tests/run-coverage/async2.rs index 21f4e65de30..2884ff297af 100644 --- a/tests/run-coverage/async2.rs +++ b/tests/run-coverage/async2.rs @@ -8,9 +8,6 @@ fn non_async_func() { } } - - - async fn async_func() { println!("async_func was covered"); let b = true; @@ -19,9 +16,6 @@ async fn async_func() { } } - - - async fn async_func_just_println() { println!("async_func_just_println was covered"); } diff --git a/tests/run-coverage/auxiliary/inline_always_with_dead_code.rs b/tests/run-coverage/auxiliary/inline_always_with_dead_code.rs index 2b21dee6ccf..9dc50dae25a 100644 --- a/tests/run-coverage/auxiliary/inline_always_with_dead_code.rs +++ b/tests/run-coverage/auxiliary/inline_always_with_dead_code.rs @@ -4,9 +4,9 @@ mod foo { #[inline(always)] - pub fn called() { } + pub fn called() {} - fn uncalled() { } + fn uncalled() {} } pub mod bar { diff --git a/tests/run-coverage/auxiliary/used_inline_crate.rs b/tests/run-coverage/auxiliary/used_inline_crate.rs index a6651dd8a5e..e8929de6b36 100644 --- a/tests/run-coverage/auxiliary/used_inline_crate.rs +++ b/tests/run-coverage/auxiliary/used_inline_crate.rs @@ -29,12 +29,6 @@ pub fn used_inline_function() { use_this_lib_crate(); } - - - - - - #[inline(always)] pub fn used_only_from_bin_crate_generic_function(arg: T) { println!("used_only_from_bin_crate_generic_function with {:?}", arg); diff --git a/tests/run-coverage/closure.coverage b/tests/run-coverage/closure.coverage index 211ba4cbe98..930348dc431 100644 --- a/tests/run-coverage/closure.coverage +++ b/tests/run-coverage/closure.coverage @@ -10,7 +10,7 @@ LL| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from LL| 1| // dependent conditions. LL| 1| let is_true = std::env::args().len() == 1; - LL| 1| let is_false = ! is_true; + LL| 1| let is_false = !is_true; LL| 1| LL| 1| let mut some_string = Some(String::from("the string content")); LL| 1| println!( diff --git a/tests/run-coverage/closure.rs b/tests/run-coverage/closure.rs index 7c42458ae1b..16a2c4e33bd 100644 --- a/tests/run-coverage/closure.rs +++ b/tests/run-coverage/closure.rs @@ -10,7 +10,7 @@ fn main() { // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from // dependent conditions. let is_true = std::env::args().len() == 1; - let is_false = ! is_true; + let is_false = !is_true; let mut some_string = Some(String::from("the string content")); println!( diff --git a/tests/run-coverage/closure_macro_async.coverage b/tests/run-coverage/closure_macro_async.coverage index 4cd40384780..018e3160e4f 100644 --- a/tests/run-coverage/closure_macro_async.coverage +++ b/tests/run-coverage/closure_macro_async.coverage @@ -57,16 +57,12 @@ LL| | let mut future = unsafe { Pin::new_unchecked(&mut future) }; LL| | use std::hint::unreachable_unchecked; LL| | static VTABLE: RawWakerVTable = RawWakerVTable::new( - LL| | LL| | #[no_coverage] LL| | |_| unsafe { unreachable_unchecked() }, // clone - LL| | LL| | #[no_coverage] LL| | |_| unsafe { unreachable_unchecked() }, // wake - LL| | LL| | #[no_coverage] LL| | |_| unsafe { unreachable_unchecked() }, // wake_by_ref - LL| | LL| | #[no_coverage] LL| | |_| (), LL| | ); diff --git a/tests/run-coverage/closure_macro_async.rs b/tests/run-coverage/closure_macro_async.rs index a90827572bb..3d6bdb38a2a 100644 --- a/tests/run-coverage/closure_macro_async.rs +++ b/tests/run-coverage/closure_macro_async.rs @@ -56,16 +56,12 @@ mod executor { let mut future = unsafe { Pin::new_unchecked(&mut future) }; use std::hint::unreachable_unchecked; static VTABLE: RawWakerVTable = RawWakerVTable::new( - #[no_coverage] |_| unsafe { unreachable_unchecked() }, // clone - #[no_coverage] |_| unsafe { unreachable_unchecked() }, // wake - #[no_coverage] |_| unsafe { unreachable_unchecked() }, // wake_by_ref - #[no_coverage] |_| (), ); diff --git a/tests/run-coverage/conditions.coverage b/tests/run-coverage/conditions.coverage index 4749c353a64..473335ff641 100644 --- a/tests/run-coverage/conditions.coverage +++ b/tests/run-coverage/conditions.coverage @@ -59,7 +59,6 @@ LL| | } LL| 0| } LL| | - LL| | LL| 1| let mut countdown = 0; LL| 1| if true { LL| 1| countdown = 1; diff --git a/tests/run-coverage/conditions.rs b/tests/run-coverage/conditions.rs index 057599d1b47..fa7f2a116c2 100644 --- a/tests/run-coverage/conditions.rs +++ b/tests/run-coverage/conditions.rs @@ -55,7 +55,6 @@ fn main() { } } - let mut countdown = 0; if true { countdown = 1; diff --git a/tests/run-coverage/drop_trait.coverage b/tests/run-coverage/drop_trait.coverage index c99b980a339..2c9439a93b1 100644 --- a/tests/run-coverage/drop_trait.coverage +++ b/tests/run-coverage/drop_trait.coverage @@ -11,7 +11,7 @@ LL| 2| } LL| |} LL| | - LL| 1|fn main() -> Result<(),u8> { + LL| 1|fn main() -> Result<(), u8> { LL| 1| let _firecracker = Firework { strength: 1 }; LL| 1| LL| 1| let _tnt = Firework { strength: 100 }; diff --git a/tests/run-coverage/drop_trait.rs b/tests/run-coverage/drop_trait.rs index a9b5d1d1e7f..7b062719c6b 100644 --- a/tests/run-coverage/drop_trait.rs +++ b/tests/run-coverage/drop_trait.rs @@ -11,7 +11,7 @@ impl Drop for Firework { } } -fn main() -> Result<(),u8> { +fn main() -> Result<(), u8> { let _firecracker = Firework { strength: 1 }; let _tnt = Firework { strength: 100 }; diff --git a/tests/run-coverage/generics.coverage b/tests/run-coverage/generics.coverage index 2ff8f917ed7..09839183566 100644 --- a/tests/run-coverage/generics.coverage +++ b/tests/run-coverage/generics.coverage @@ -41,7 +41,7 @@ ------------------ LL| |} LL| | - LL| 1|fn main() -> Result<(),u8> { + LL| 1|fn main() -> Result<(), u8> { LL| 1| let mut firecracker = Firework { strength: 1 }; LL| 1| firecracker.set_strength(2); LL| 1| @@ -54,10 +54,6 @@ LL| 1| return Err(1); LL| 0| } LL| 0| - LL| 0| - LL| 0| - LL| 0| - LL| 0| LL| 0| let _ = Firework { strength: 1000 }; LL| 0| LL| 0| Ok(()) diff --git a/tests/run-coverage/generics.rs b/tests/run-coverage/generics.rs index 150ffb9db39..bf4c2d8d685 100644 --- a/tests/run-coverage/generics.rs +++ b/tests/run-coverage/generics.rs @@ -19,7 +19,7 @@ impl Drop for Firework where T: Copy + std::fmt::Display { } } -fn main() -> Result<(),u8> { +fn main() -> Result<(), u8> { let mut firecracker = Firework { strength: 1 }; firecracker.set_strength(2); @@ -32,10 +32,6 @@ fn main() -> Result<(),u8> { return Err(1); } - - - - let _ = Firework { strength: 1000 }; Ok(()) diff --git a/tests/run-coverage/issue-85461.coverage b/tests/run-coverage/issue-85461.coverage index 48e76318b0a..cbc910664d0 100644 --- a/tests/run-coverage/issue-85461.coverage +++ b/tests/run-coverage/issue-85461.coverage @@ -5,9 +5,9 @@ $DIR/auxiliary/inline_always_with_dead_code.rs: LL| | LL| |mod foo { LL| | #[inline(always)] - LL| 2| pub fn called() { } + LL| 2| pub fn called() {} LL| | - LL| 0| fn uncalled() { } + LL| 0| fn uncalled() {} LL| |} LL| | LL| |pub mod bar { diff --git a/tests/run-coverage/issue-93054.coverage b/tests/run-coverage/issue-93054.coverage index 224c01d9a8b..15f225326a4 100644 --- a/tests/run-coverage/issue-93054.coverage +++ b/tests/run-coverage/issue-93054.coverage @@ -6,26 +6,26 @@ LL| | LL| |// compile-flags: --edition=2021 LL| | - LL| |enum Never { } + LL| |enum Never {} LL| | LL| |impl Never { LL| | fn foo(self) { - LL| | match self { } - LL| | make().map(|never| match never { }); + LL| | match self {} + LL| | make().map(|never| match never {}); LL| | } LL| | LL| | fn bar(&self) { - LL| | match *self { } + LL| | match *self {} LL| | } LL| |} LL| | LL| 0|async fn foo2(never: Never) { - LL| | match never { } + LL| | match never {} LL| |} LL| | LL| 0|fn make() -> Option { LL| 0| None LL| 0|} LL| | - LL| 1|fn main() { } + LL| 1|fn main() {} diff --git a/tests/run-coverage/issue-93054.rs b/tests/run-coverage/issue-93054.rs index 9f695b7fd11..da546cfeef8 100644 --- a/tests/run-coverage/issue-93054.rs +++ b/tests/run-coverage/issue-93054.rs @@ -6,25 +6,25 @@ // compile-flags: --edition=2021 -enum Never { } +enum Never {} impl Never { fn foo(self) { - match self { } - make().map(|never| match never { }); + match self {} + make().map(|never| match never {}); } fn bar(&self) { - match *self { } + match *self {} } } async fn foo2(never: Never) { - match never { } + match never {} } fn make() -> Option { None } -fn main() { } +fn main() {} diff --git a/tests/run-coverage/loops_branches.coverage b/tests/run-coverage/loops_branches.coverage index 148a22377f3..8cd6f1be3f7 100644 --- a/tests/run-coverage/loops_branches.coverage +++ b/tests/run-coverage/loops_branches.coverage @@ -9,8 +9,7 @@ LL| 1| fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { LL| 1| if true { LL| 1| if false { - LL| 0| while true { - LL| 0| } + LL| 0| while true {} LL| 1| } LL| 1| write!(f, "cool")?; ^0 diff --git a/tests/run-coverage/loops_branches.rs b/tests/run-coverage/loops_branches.rs index 7116ce47f4b..f3a343bcc1f 100644 --- a/tests/run-coverage/loops_branches.rs +++ b/tests/run-coverage/loops_branches.rs @@ -9,8 +9,7 @@ impl std::fmt::Debug for DebugTest { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { if true { if false { - while true { - } + while true {} } write!(f, "cool")?; } else { diff --git a/tests/run-coverage/overflow.coverage b/tests/run-coverage/overflow.coverage index 2d60316e215..cee076e88cd 100644 --- a/tests/run-coverage/overflow.coverage +++ b/tests/run-coverage/overflow.coverage @@ -12,7 +12,7 @@ LL| 4| result LL| 4|} LL| | - LL| 1|fn main() -> Result<(),u8> { + LL| 1|fn main() -> Result<(), u8> { LL| 1| let mut countdown = 10; LL| 11| while countdown > 0 { LL| 11| if countdown == 1 { diff --git a/tests/run-coverage/overflow.rs b/tests/run-coverage/overflow.rs index 7df8de6f3cd..bbb65c1b35d 100644 --- a/tests/run-coverage/overflow.rs +++ b/tests/run-coverage/overflow.rs @@ -12,7 +12,7 @@ fn might_overflow(to_add: u32) -> u32 { result } -fn main() -> Result<(),u8> { +fn main() -> Result<(), u8> { let mut countdown = 10; while countdown > 0 { if countdown == 1 { diff --git a/tests/run-coverage/try_error_result.coverage b/tests/run-coverage/try_error_result.coverage index fcdb7437d00..5d48cbd62f2 100644 --- a/tests/run-coverage/try_error_result.coverage +++ b/tests/run-coverage/try_error_result.coverage @@ -1,7 +1,7 @@ LL| |#![allow(unused_assignments)] LL| |// failure-status: 1 LL| | - LL| 6|fn call(return_error: bool) -> Result<(),()> { + LL| 6|fn call(return_error: bool) -> Result<(), ()> { LL| 6| if return_error { LL| 1| Err(()) LL| | } else { @@ -9,7 +9,7 @@ LL| | } LL| 6|} LL| | - LL| 1|fn test1() -> Result<(),()> { + LL| 1|fn test1() -> Result<(), ()> { LL| 1| let mut LL| 1| countdown = 10 LL| | ; @@ -38,18 +38,18 @@ LL| | LL| |struct Thing1; LL| |impl Thing1 { - LL| 18| fn get_thing_2(&self, return_error: bool) -> Result { + LL| 18| fn get_thing_2(&self, return_error: bool) -> Result { LL| 18| if return_error { LL| 1| Err(()) LL| | } else { - LL| 17| Ok(Thing2{}) + LL| 17| Ok(Thing2 {}) LL| | } LL| 18| } LL| |} LL| | LL| |struct Thing2; LL| |impl Thing2 { - LL| 17| fn call(&self, return_error: bool) -> Result { + LL| 17| fn call(&self, return_error: bool) -> Result { LL| 17| if return_error { LL| 2| Err(()) LL| | } else { @@ -58,7 +58,7 @@ LL| 17| } LL| |} LL| | - LL| 1|fn test2() -> Result<(),()> { + LL| 1|fn test2() -> Result<(), ()> { LL| 1| let thing1 = Thing1{}; LL| 1| let mut LL| 1| countdown = 10 @@ -115,7 +115,7 @@ LL| 0| Ok(()) LL| 1|} LL| | - LL| 1|fn main() -> Result<(),()> { + LL| 1|fn main() -> Result<(), ()> { LL| 1| test1().expect_err("test1 should fail"); LL| 1| test2() LL| 1| ? diff --git a/tests/run-coverage/try_error_result.rs b/tests/run-coverage/try_error_result.rs index 9eb1d2db218..557cbf22bfa 100644 --- a/tests/run-coverage/try_error_result.rs +++ b/tests/run-coverage/try_error_result.rs @@ -1,7 +1,7 @@ #![allow(unused_assignments)] // failure-status: 1 -fn call(return_error: bool) -> Result<(),()> { +fn call(return_error: bool) -> Result<(), ()> { if return_error { Err(()) } else { @@ -9,7 +9,7 @@ fn call(return_error: bool) -> Result<(),()> { } } -fn test1() -> Result<(),()> { +fn test1() -> Result<(), ()> { let mut countdown = 10 ; @@ -37,18 +37,18 @@ fn test1() -> Result<(),()> { struct Thing1; impl Thing1 { - fn get_thing_2(&self, return_error: bool) -> Result { + fn get_thing_2(&self, return_error: bool) -> Result { if return_error { Err(()) } else { - Ok(Thing2{}) + Ok(Thing2 {}) } } } struct Thing2; impl Thing2 { - fn call(&self, return_error: bool) -> Result { + fn call(&self, return_error: bool) -> Result { if return_error { Err(()) } else { @@ -57,7 +57,7 @@ impl Thing2 { } } -fn test2() -> Result<(),()> { +fn test2() -> Result<(), ()> { let thing1 = Thing1{}; let mut countdown = 10 @@ -109,7 +109,7 @@ fn test2() -> Result<(),()> { Ok(()) } -fn main() -> Result<(),()> { +fn main() -> Result<(), ()> { test1().expect_err("test1 should fail"); test2() ? diff --git a/tests/run-coverage/uses_inline_crate.coverage b/tests/run-coverage/uses_inline_crate.coverage index c510b6a6c68..cc0e01ffde1 100644 --- a/tests/run-coverage/uses_inline_crate.coverage +++ b/tests/run-coverage/uses_inline_crate.coverage @@ -32,12 +32,6 @@ $DIR/auxiliary/used_inline_crate.rs: LL| 1| use_this_lib_crate(); LL| 1|} LL| | - LL| | - LL| | - LL| | - LL| | - LL| | - LL| | LL| |#[inline(always)] LL| 2|pub fn used_only_from_bin_crate_generic_function(arg: T) { LL| 2| println!("used_only_from_bin_crate_generic_function with {:?}", arg); diff --git a/tests/run-coverage/while_early_ret.coverage b/tests/run-coverage/while_early_ret.coverage index 97808447ab7..49d39d36603 100644 --- a/tests/run-coverage/while_early_ret.coverage +++ b/tests/run-coverage/while_early_ret.coverage @@ -1,7 +1,7 @@ LL| |#![allow(unused_assignments)] LL| |// failure-status: 1 LL| | - LL| 1|fn main() -> Result<(),u8> { + LL| 1|fn main() -> Result<(), u8> { LL| 1| let mut countdown = 10; LL| | while LL| 7| countdown diff --git a/tests/run-coverage/while_early_ret.rs b/tests/run-coverage/while_early_ret.rs index 1c83c8fc7a8..b2f0eee2cc0 100644 --- a/tests/run-coverage/while_early_ret.rs +++ b/tests/run-coverage/while_early_ret.rs @@ -1,7 +1,7 @@ #![allow(unused_assignments)] // failure-status: 1 -fn main() -> Result<(),u8> { +fn main() -> Result<(), u8> { let mut countdown = 10; while countdown diff --git a/tests/run-coverage/yield.coverage b/tests/run-coverage/yield.coverage index 383dd991500..90c2641a7d6 100644 --- a/tests/run-coverage/yield.coverage +++ b/tests/run-coverage/yield.coverage @@ -7,7 +7,7 @@ LL| 1|fn main() { LL| 1| let mut generator = || { LL| 1| yield 1; - LL| 1| return "foo" + LL| 1| return "foo"; LL| 1| }; LL| | LL| 1| match Pin::new(&mut generator).resume(()) { @@ -23,7 +23,7 @@ LL| 1| yield 1; LL| 1| yield 2; LL| 0| yield 3; - LL| 0| return "foo" + LL| 0| return "foo"; LL| 0| }; LL| | LL| 1| match Pin::new(&mut generator).resume(()) { diff --git a/tests/run-coverage/yield.rs b/tests/run-coverage/yield.rs index ff7616656ff..361275c9215 100644 --- a/tests/run-coverage/yield.rs +++ b/tests/run-coverage/yield.rs @@ -7,7 +7,7 @@ use std::pin::Pin; fn main() { let mut generator = || { yield 1; - return "foo" + return "foo"; }; match Pin::new(&mut generator).resume(()) { @@ -23,7 +23,7 @@ fn main() { yield 1; yield 2; yield 3; - return "foo" + return "foo"; }; match Pin::new(&mut generator).resume(()) {