Skip to content

Commit be416b9

Browse files
authored
Rollup merge of #114924 - Zalathar:tidy-tests, r=Mark-Simulacrum
coverage: Tidy up `run-coverage` tests in several small ways Prior to #114875 (anonymized line numbers), these tests were very sensitive to lines being added/removed, since doing so would change the line numbers in every subsequent line of output. Therefore they ended up with a few small style issues that weren't worth the hassle of fixing. Now that we can freely rearrange lines without needing to re-bless the entire output, we can tidy up the tests in various trivial ways.
2 parents e877e2a + 8d91e71 commit be416b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+100
-122
lines changed

tests/run-coverage-rustdoc/doctest.coverage

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ $DIR/auxiliary/doctest_crate.rs:
1010
LL| 3|}
1111

1212
$DIR/doctest.rs:
13+
LL| |// aux-build:doctest_crate.rs
14+
LL| |
1315
LL| |//! This test ensures that code from doctests is properly re-mapped.
1416
LL| |//! See <https://github.com/rust-lang/rust/issues/79417> for more info.
1517
LL| |//!
@@ -78,7 +80,7 @@ $DIR/doctest.rs:
7880
LL| |//! doctest_main()
7981
LL| |//! }
8082
LL| |//! ```
81-
LL| |// aux-build:doctest_crate.rs
83+
LL| |
8284
LL| |/// doctest attached to fn testing external code:
8385
LL| |/// ```
8486
LL| 1|/// extern crate doctest_crate;

tests/run-coverage-rustdoc/doctest.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// aux-build:doctest_crate.rs
2+
13
//! This test ensures that code from doctests is properly re-mapped.
24
//! See <https://github.com/rust-lang/rust/issues/79417> for more info.
35
//!
@@ -63,7 +65,7 @@
6365
//! doctest_main()
6466
//! }
6567
//! ```
66-
// aux-build:doctest_crate.rs
68+
6769
/// doctest attached to fn testing external code:
6870
/// ```
6971
/// extern crate doctest_crate;

tests/run-coverage/assert.coverage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
^1
88
LL| 3|}
99
LL| |
10-
LL| 1|fn main() -> Result<(),u8> {
10+
LL| 1|fn main() -> Result<(), u8> {
1111
LL| 1| let mut countdown = 10;
1212
LL| 11| while countdown > 0 {
1313
LL| 11| if countdown == 1 {

tests/run-coverage/assert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn might_fail_assert(one_plus_one: u32) {
66
assert_eq!(1 + 1, one_plus_one, "the argument was wrong");
77
}
88

9-
fn main() -> Result<(),u8> {
9+
fn main() -> Result<(), u8> {
1010
let mut countdown = 10;
1111
while countdown > 0 {
1212
if countdown == 1 {

tests/run-coverage/async2.coverage

Lines changed: 0 additions & 12 deletions
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;
@@ -15,9 +9,6 @@
159
^0
1610
LL| 1|}
1711
LL| |
18-
LL| |
19-
LL| |
20-
LL| |
2112
LL| 1|async fn async_func() {
2213
LL| 1| println!("async_func was covered");
2314
LL| 1| let b = true;
@@ -27,9 +18,6 @@
2718
^0
2819
LL| 1|}
2920
LL| |
30-
LL| |
31-
LL| |
32-
LL| |
3321
LL| 1|async fn async_func_just_println() {
3422
LL| 1| println!("async_func_just_println was covered");
3523
LL| 1|}

tests/run-coverage/async2.rs

Lines changed: 0 additions & 12 deletions
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;
@@ -14,9 +8,6 @@ fn non_async_func() {
148
}
159
}
1610

17-
18-
19-
2011
async fn async_func() {
2112
println!("async_func was covered");
2213
let b = true;
@@ -25,9 +16,6 @@ async fn async_func() {
2516
}
2617
}
2718

28-
29-
30-
3119
async fn async_func_just_println() {
3220
println!("async_func_just_println was covered");
3321
}

tests/run-coverage/auxiliary/inline_always_with_dead_code.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
mod foo {
66
#[inline(always)]
7-
pub fn called() { }
7+
pub fn called() {}
88

9-
fn uncalled() { }
9+
fn uncalled() {}
1010
}
1111

1212
pub mod bar {
Lines changed: 1 addition & 0 deletions
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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#![allow(unused_assignments, unused_variables)]
2+
// Verify that coverage works with optimizations:
23
// compile-flags: -C opt-level=3
3-
use std::fmt::Debug; // ^^ validates coverage now works with optimizations
4+
5+
use std::fmt::Debug;
46

57
pub fn used_function() {
68
// Initialize test constants in a way that cannot be determined at compile time, to ensure
@@ -42,6 +44,7 @@ pub fn unused_function() {
4244
}
4345
}
4446

47+
#[allow(dead_code)]
4548
fn unused_private_function() {
4649
let is_true = std::env::args().len() == 1;
4750
let mut countdown = 2;

tests/run-coverage/auxiliary/used_inline_crate.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(unused_assignments, unused_variables)]
2-
2+
// Verify that coverage works with optimizations:
33
// compile-flags: -C opt-level=3
4-
// ^^ validates coverage now works with optimizations
4+
55
use std::fmt::Debug;
66

77
pub fn used_function() {
@@ -29,12 +29,6 @@ pub fn used_inline_function() {
2929
use_this_lib_crate();
3030
}
3131

32-
33-
34-
35-
36-
37-
3832
#[inline(always)]
3933
pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
4034
println!("used_only_from_bin_crate_generic_function with {:?}", arg);
@@ -71,6 +65,7 @@ pub fn unused_function() {
7165
}
7266

7367
#[inline(always)]
68+
#[allow(dead_code)]
7469
fn unused_private_function() {
7570
let is_true = std::env::args().len() == 1;
7671
let mut countdown = 2;

0 commit comments

Comments
 (0)