Skip to content

Commit

Permalink
Tweak various coverage test files for slightly nicer formatting
Browse files Browse the repository at this point in the history
For coverage tests, splitting code across multiple lines often makes the
resulting coverage report easier to interpret, so we force rustfmt to retain
line breaks by adding dummy line comments with `//`.
  • Loading branch information
Zalathar committed May 29, 2024
1 parent da159eb commit 448d63e
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 58 deletions.
10 changes: 5 additions & 5 deletions tests/coverage/auxiliary/used_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ pub fn used_function() {
}

pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
println!("used_only_from_bin_crate_generic_function with {:?}", arg);
println!("used_only_from_bin_crate_generic_function with {arg:?}");
}
// Expect for above function: `Unexecuted instantiation` (see below)
pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
println!("used_only_from_this_lib_crate_generic_function with {arg:?}");
}

pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
println!("used_from_bin_crate_and_lib_crate_generic_function with {arg:?}");
}

pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {arg:?}");
}

pub fn unused_generic_function<T: Debug>(arg: T) {
println!("unused_generic_function with {:?}", arg);
println!("unused_generic_function with {arg:?}");
}

pub fn unused_function() {
Expand Down
10 changes: 5 additions & 5 deletions tests/coverage/auxiliary/used_inline_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,28 @@ pub fn used_inline_function() {

#[inline(always)]
pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
println!("used_only_from_bin_crate_generic_function with {:?}", arg);
println!("used_only_from_bin_crate_generic_function with {arg:?}");
}
// Expect for above function: `Unexecuted instantiation` (see notes in `used_crate.rs`)

#[inline(always)]
pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
println!("used_only_from_this_lib_crate_generic_function with {arg:?}");
}

#[inline(always)]
pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
println!("used_from_bin_crate_and_lib_crate_generic_function with {arg:?}");
}

#[inline(always)]
pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {arg:?}");
}

#[inline(always)]
pub fn unused_generic_function<T: Debug>(arg: T) {
println!("unused_generic_function with {:?}", arg);
println!("unused_generic_function with {arg:?}");
}

#[inline(always)]
Expand Down
4 changes: 2 additions & 2 deletions tests/coverage/coroutine.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
LL| |// to handle this condition, and still report dead block coverage.
LL| 1|fn get_u32(val: bool) -> Result<u32, String> {
LL| 1| if val {
LL| 1| Ok(1)
LL| 1| Ok(1) //
LL| | } else {
LL| 0| Err(String::from("some error"))
LL| 0| Err(String::from("some error")) //
LL| | }
LL| 1|}
LL| |
Expand Down
4 changes: 2 additions & 2 deletions tests/coverage/coroutine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use std::pin::Pin;
// to handle this condition, and still report dead block coverage.
fn get_u32(val: bool) -> Result<u32, String> {
if val {
Ok(1)
Ok(1) //
} else {
Err(String::from("some error"))
Err(String::from("some error")) //
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/coverage/inline-dead.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
LL| |#[inline]
LL| 1|fn live<const B: bool>() -> u32 {
LL| 1| if B {
LL| 0| dead()
LL| 0| dead() //
LL| | } else {
LL| 1| 0
LL| | }
Expand Down
2 changes: 1 addition & 1 deletion tests/coverage/inline-dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn main() {
#[inline]
fn live<const B: bool>() -> u32 {
if B {
dead()
dead() //
} else {
0
}
Expand Down
2 changes: 1 addition & 1 deletion tests/coverage/inner_items.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
^0
LL| |
LL| 1| let mut val = InStruct {
LL| 1| in_struct_field: 101,
LL| 1| in_struct_field: 101, //
LL| 1| };
LL| 1|
LL| 1| val.default_trait_func();
Expand Down
2 changes: 1 addition & 1 deletion tests/coverage/inner_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn main() {
}

let mut val = InStruct {
in_struct_field: 101,
in_struct_field: 101, //
};

val.default_trait_func();
Expand Down
2 changes: 1 addition & 1 deletion tests/coverage/partial_eq.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
LL| 1| "{:?} < {:?} = {}",
LL| 1| version_3_2_1,
LL| 1| version_3_3_0,
LL| 1| version_3_2_1 < version_3_3_0
LL| 1| version_3_2_1 < version_3_3_0, //
LL| 1| );
LL| 1|}
LL| |
Expand Down
2 changes: 1 addition & 1 deletion tests/coverage/partial_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn main() {
"{:?} < {:?} = {}",
version_3_2_1,
version_3_3_0,
version_3_2_1 < version_3_3_0
version_3_2_1 < version_3_3_0, //
);
}

Expand Down
12 changes: 6 additions & 6 deletions tests/coverage/try_error_result.cov-map
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,26 @@ Number of file 0 mappings: 4
- Code(Counter(0)) at (prev + 2, 5) to (start + 0, 6)

Function name: try_error_result::call
Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 04, 01, 01, 14, 05, 02, 09, 00, 10, 02, 02, 09, 00, 0f, 01, 02, 01, 00, 02]
Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 05, 01, 01, 14, 05, 02, 09, 00, 10, 02, 02, 09, 00, 0f, 01, 02, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 1
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
Number of file 0 mappings: 4
- Code(Counter(0)) at (prev + 4, 1) to (start + 1, 20)
- Code(Counter(0)) at (prev + 5, 1) to (start + 1, 20)
- Code(Counter(1)) at (prev + 2, 9) to (start + 0, 16)
- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 15)
= (c0 - c1)
- Code(Counter(0)) at (prev + 2, 1) to (start + 0, 2)

Function name: try_error_result::main
Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 73, 01, 02, 0c, 05, 03, 05, 00, 06, 02, 02, 05, 00, 0b, 01, 01, 01, 00, 02]
Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 71, 01, 02, 0c, 05, 03, 05, 00, 06, 02, 02, 05, 00, 0b, 01, 01, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 1
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
Number of file 0 mappings: 4
- Code(Counter(0)) at (prev + 115, 1) to (start + 2, 12)
- Code(Counter(0)) at (prev + 113, 1) to (start + 2, 12)
- Code(Counter(1)) at (prev + 3, 5) to (start + 0, 6)
- Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 0, 11)
= (c0 - c1)
Expand Down Expand Up @@ -81,7 +81,7 @@ Number of file 0 mappings: 11
= (((c4 + Zero) + Zero) + c3)

Function name: try_error_result::test2
Raw bytes (280): 0x[01, 01, 24, 01, 07, 00, 09, 03, 0d, 41, 00, 1e, 00, 41, 00, 1e, 00, 41, 00, 4a, 00, 4e, 00, 52, 41, 03, 0d, 52, 41, 03, 0d, 4e, 00, 52, 41, 03, 0d, 4a, 00, 4e, 00, 52, 41, 03, 0d, 66, 00, 45, 00, 45, 00, 66, 00, 45, 00, 7a, 00, 4d, 00, 4d, 00, 7a, 00, 4d, 00, 83, 01, 0d, 87, 01, 00, 00, 8b, 01, 8f, 01, 00, 19, 00, 28, 01, 3e, 01, 03, 17, 03, 08, 09, 00, 0e, 52, 02, 09, 04, 1a, 41, 06, 0d, 00, 2f, 00, 00, 2f, 00, 30, 1e, 00, 31, 03, 35, 00, 04, 11, 00, 12, 1a, 02, 11, 04, 12, 00, 05, 11, 00, 14, 1a, 00, 17, 00, 41, 19, 00, 41, 00, 42, 00, 00, 43, 00, 5f, 00, 00, 5f, 00, 60, 00, 01, 0d, 00, 20, 00, 01, 11, 00, 14, 00, 00, 17, 00, 41, 00, 00, 41, 00, 42, 00, 00, 43, 00, 60, 00, 00, 60, 00, 61, 00, 01, 0d, 00, 20, 46, 04, 11, 00, 14, 4e, 00, 17, 00, 42, 00, 00, 42, 00, 43, 4a, 00, 44, 00, 61, 00, 00, 61, 00, 62, 46, 01, 0d, 00, 20, 62, 01, 11, 00, 14, 45, 00, 17, 01, 36, 00, 01, 36, 00, 37, 66, 01, 12, 00, 2f, 00, 00, 2f, 00, 30, 62, 01, 0d, 00, 20, 76, 01, 11, 00, 14, 4d, 00, 17, 01, 36, 00, 02, 11, 00, 12, 7a, 01, 12, 00, 2f, 00, 01, 11, 00, 12, 76, 02, 0d, 00, 20, 0d, 03, 05, 00, 0b, 7f, 01, 01, 00, 02]
Raw bytes (280): 0x[01, 01, 24, 01, 07, 00, 09, 03, 0d, 41, 00, 1e, 00, 41, 00, 1e, 00, 41, 00, 4a, 00, 4e, 00, 52, 41, 03, 0d, 52, 41, 03, 0d, 4e, 00, 52, 41, 03, 0d, 4a, 00, 4e, 00, 52, 41, 03, 0d, 66, 00, 45, 00, 45, 00, 66, 00, 45, 00, 7a, 00, 4d, 00, 4d, 00, 7a, 00, 4d, 00, 83, 01, 0d, 87, 01, 00, 00, 8b, 01, 8f, 01, 00, 19, 00, 28, 01, 3d, 01, 03, 17, 03, 08, 09, 00, 0e, 52, 02, 09, 04, 1a, 41, 06, 0d, 00, 2f, 00, 00, 2f, 00, 30, 1e, 00, 31, 03, 35, 00, 04, 11, 00, 12, 1a, 02, 11, 04, 12, 00, 05, 11, 00, 14, 1a, 00, 17, 00, 41, 19, 00, 41, 00, 42, 00, 00, 43, 00, 5f, 00, 00, 5f, 00, 60, 00, 01, 0d, 00, 20, 00, 01, 11, 00, 14, 00, 00, 17, 00, 41, 00, 00, 41, 00, 42, 00, 00, 43, 00, 60, 00, 00, 60, 00, 61, 00, 01, 0d, 00, 20, 46, 04, 11, 00, 14, 4e, 00, 17, 00, 42, 00, 00, 42, 00, 43, 4a, 00, 44, 00, 61, 00, 00, 61, 00, 62, 46, 01, 0d, 00, 20, 62, 01, 11, 00, 14, 45, 00, 17, 01, 36, 00, 01, 36, 00, 37, 66, 01, 12, 00, 2f, 00, 00, 2f, 00, 30, 62, 01, 0d, 00, 20, 76, 01, 11, 00, 14, 4d, 00, 17, 01, 36, 00, 02, 11, 00, 12, 7a, 01, 12, 00, 2f, 00, 01, 11, 00, 12, 76, 02, 0d, 00, 20, 0d, 03, 05, 00, 0b, 7f, 01, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 36
Expand Down Expand Up @@ -122,7 +122,7 @@ Number of expressions: 36
- expression 34 operands: lhs = Expression(35, Add), rhs = Zero
- expression 35 operands: lhs = Counter(6), rhs = Zero
Number of file 0 mappings: 40
- Code(Counter(0)) at (prev + 62, 1) to (start + 3, 23)
- Code(Counter(0)) at (prev + 61, 1) to (start + 3, 23)
- Code(Expression(0, Add)) at (prev + 8, 9) to (start + 0, 14)
= (c0 + (Zero + c2))
- Code(Expression(20, Sub)) at (prev + 2, 9) to (start + 4, 26)
Expand Down
4 changes: 1 addition & 3 deletions tests/coverage/try_error_result.coverage
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
LL| |#![allow(unused_assignments)]
LL| |#![cfg_attr(rustfmt, rustfmt::skip)]
LL| |//@ failure-status: 1
LL| |
LL| 6|fn call(return_error: bool) -> Result<(), ()> {
Expand All @@ -9,7 +10,6 @@
LL| | }
LL| 6|}
LL| |
LL| |#[rustfmt::skip]
LL| 1|fn test1() -> Result<(), ()> {
LL| 1| let mut
LL| 1| countdown = 10
Expand Down Expand Up @@ -59,7 +59,6 @@
LL| 17| }
LL| |}
LL| |
LL| |#[rustfmt::skip]
LL| 1|fn test2() -> Result<(), ()> {
LL| 1| let thing1 = Thing1{};
LL| 1| let mut
Expand Down Expand Up @@ -117,7 +116,6 @@
LL| 0| Ok(())
LL| 1|}
LL| |
LL| |#[rustfmt::skip]
LL| 1|fn main() -> Result<(), ()> {
LL| 1| test1().expect_err("test1 should fail");
LL| 1| test2()
Expand Down
4 changes: 1 addition & 3 deletions tests/coverage/try_error_result.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(unused_assignments)]
#![cfg_attr(rustfmt, rustfmt::skip)]
//@ failure-status: 1

fn call(return_error: bool) -> Result<(), ()> {
Expand All @@ -9,7 +10,6 @@ fn call(return_error: bool) -> Result<(), ()> {
}
}

#[rustfmt::skip]
fn test1() -> Result<(), ()> {
let mut
countdown = 10
Expand Down Expand Up @@ -58,7 +58,6 @@ impl Thing2 {
}
}

#[rustfmt::skip]
fn test2() -> Result<(), ()> {
let thing1 = Thing1{};
let mut
Expand Down Expand Up @@ -111,7 +110,6 @@ fn test2() -> Result<(), ()> {
Ok(())
}

#[rustfmt::skip]
fn main() -> Result<(), ()> {
test1().expect_err("test1 should fail");
test2()
Expand Down
26 changes: 13 additions & 13 deletions tests/coverage/uses_crate.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -19,69 +19,69 @@ $DIR/auxiliary/used_crate.rs:
LL| 1|}
LL| |
LL| 2|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
LL| 2| println!("used_only_from_bin_crate_generic_function with {:?}", arg);
LL| 2| println!("used_only_from_bin_crate_generic_function with {arg:?}");
LL| 2|}
------------------
| Unexecuted instantiation: used_crate::used_only_from_bin_crate_generic_function::<_>
------------------
| used_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec<i32>>:
| LL| 1|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
| LL| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg);
| LL| 1| println!("used_only_from_bin_crate_generic_function with {arg:?}");
| LL| 1|}
------------------
| used_crate::used_only_from_bin_crate_generic_function::<&str>:
| LL| 1|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
| LL| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg);
| LL| 1| println!("used_only_from_bin_crate_generic_function with {arg:?}");
| LL| 1|}
------------------
LL| |// Expect for above function: `Unexecuted instantiation` (see below)
LL| 2|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
LL| 2| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
LL| 2| println!("used_only_from_this_lib_crate_generic_function with {arg:?}");
LL| 2|}
------------------
| used_crate::used_only_from_this_lib_crate_generic_function::<&str>:
| LL| 1|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
| LL| 1| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
| LL| 1| println!("used_only_from_this_lib_crate_generic_function with {arg:?}");
| LL| 1|}
------------------
| used_crate::used_only_from_this_lib_crate_generic_function::<alloc::vec::Vec<i32>>:
| LL| 1|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
| LL| 1| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
| LL| 1| println!("used_only_from_this_lib_crate_generic_function with {arg:?}");
| LL| 1|}
------------------
LL| |
LL| 2|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
LL| 2| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
LL| 2| println!("used_from_bin_crate_and_lib_crate_generic_function with {arg:?}");
LL| 2|}
------------------
| used_crate::used_from_bin_crate_and_lib_crate_generic_function::<&str>:
| LL| 1|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
| LL| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
| LL| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {arg:?}");
| LL| 1|}
------------------
| used_crate::used_from_bin_crate_and_lib_crate_generic_function::<alloc::vec::Vec<i32>>:
| LL| 1|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
| LL| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
| LL| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {arg:?}");
| LL| 1|}
------------------
LL| |
LL| 2|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
LL| 2| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
LL| 2| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {arg:?}");
LL| 2|}
------------------
| used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str>:
| LL| 1|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
| LL| 1| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
| LL| 1| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {arg:?}");
| LL| 1|}
------------------
| used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str>:
| LL| 1|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
| LL| 1| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
| LL| 1| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {arg:?}");
| LL| 1|}
------------------
LL| |
LL| 0|pub fn unused_generic_function<T: Debug>(arg: T) {
LL| 0| println!("unused_generic_function with {:?}", arg);
LL| 0| println!("unused_generic_function with {arg:?}");
LL| 0|}
LL| |
LL| 0|pub fn unused_function() {
Expand Down
Loading

0 comments on commit 448d63e

Please sign in to comment.