Skip to content

Commit

Permalink
Unrolled build for rust-lang#125693
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#125693 - Zalathar:format, r=lqd

Format all source files in `tests/coverage/`

Currently we can't automatically enforce formatting on tests (see rust-lang#125637), but we can at least keep things relatively tidy by occasionally running the formatter manually.

This was done by temporarily commenting out the `"/tests/"` exclusion in `rustfmt.toml`, and then running:
- `x fmt tests/coverage`
- `x test coverage --bless`

(This PR also includes a few cosmetic tweaks to some of the affected files, to convince rustfmt to format them in the way we want.)

``@rustbot`` label +A-code-coverage
  • Loading branch information
rust-timer committed May 29, 2024
2 parents e9b7aa0 + 9dc6e08 commit d1d8b3b
Show file tree
Hide file tree
Showing 23 changed files with 88 additions and 102 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
8 changes: 4 additions & 4 deletions tests/coverage/coroutine.cov-map
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Number of file 0 mappings: 4
- Code(Counter(0)) at (prev + 2, 1) to (start + 0, 2)

Function name: coroutine::main
Raw bytes (65): 0x[01, 01, 08, 07, 0d, 05, 09, 11, 15, 1e, 19, 11, 15, 15, 19, 1e, 19, 11, 15, 09, 01, 13, 01, 02, 16, 01, 07, 0b, 00, 2e, 11, 01, 2b, 00, 2d, 03, 01, 0e, 00, 35, 11, 02, 0b, 00, 2e, 1e, 01, 22, 00, 27, 1a, 00, 2c, 00, 2e, 17, 01, 0e, 00, 35, 1a, 02, 01, 00, 02]
Raw bytes (65): 0x[01, 01, 08, 07, 0d, 05, 09, 11, 15, 1e, 19, 11, 15, 15, 19, 1e, 19, 11, 15, 09, 01, 13, 01, 02, 16, 01, 08, 0b, 00, 2e, 11, 01, 2b, 00, 2d, 03, 01, 0e, 00, 35, 11, 02, 0b, 00, 2e, 1e, 01, 22, 00, 27, 1a, 00, 2c, 00, 2e, 17, 01, 0e, 00, 35, 1a, 02, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 8
Expand All @@ -26,7 +26,7 @@ Number of expressions: 8
- expression 7 operands: lhs = Counter(4), rhs = Counter(5)
Number of file 0 mappings: 9
- Code(Counter(0)) at (prev + 19, 1) to (start + 2, 22)
- Code(Counter(0)) at (prev + 7, 11) to (start + 0, 46)
- Code(Counter(0)) at (prev + 8, 11) to (start + 0, 46)
- Code(Counter(4)) at (prev + 1, 43) to (start + 0, 45)
- Code(Expression(0, Add)) at (prev + 1, 14) to (start + 0, 53)
= ((c1 + c2) + c3)
Expand All @@ -41,11 +41,11 @@ Number of file 0 mappings: 9
= ((c4 - c5) - c6)

Function name: coroutine::main::{closure#0}
Raw bytes (14): 0x[01, 01, 00, 02, 01, 15, 29, 01, 1f, 05, 02, 10, 01, 06]
Raw bytes (14): 0x[01, 01, 00, 02, 01, 16, 08, 01, 1f, 05, 02, 10, 01, 06]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 2
- Code(Counter(0)) at (prev + 21, 41) to (start + 1, 31)
- Code(Counter(0)) at (prev + 22, 8) to (start + 1, 31)
- Code(Counter(1)) at (prev + 2, 16) to (start + 1, 6)

7 changes: 4 additions & 3 deletions tests/coverage/coroutine.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
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| |
LL| 1|fn main() {
LL| 1| let is_true = std::env::args().len() == 1;
LL| 1| let mut coroutine = #[coroutine] || {
LL| 1| let mut coroutine = #[coroutine]
LL| 1| || {
LL| 1| yield get_u32(is_true);
LL| 1| return "foo";
LL| 1| };
Expand Down
7 changes: 4 additions & 3 deletions tests/coverage/coroutine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ 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")) //
}
}

fn main() {
let is_true = std::env::args().len() == 1;
let mut coroutine = #[coroutine] || {
let mut coroutine = #[coroutine]
|| {
yield get_u32(is_true);
return "foo";
};
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
6 changes: 3 additions & 3 deletions tests/coverage/let_else_loop.cov-map
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Function name: let_else_loop::_if (unused)
Raw bytes (19): 0x[01, 01, 00, 03, 00, 16, 01, 01, 0c, 00, 02, 09, 00, 10, 00, 02, 09, 00, 10]
Raw bytes (19): 0x[01, 01, 00, 03, 00, 16, 01, 01, 0c, 00, 01, 0f, 00, 16, 00, 00, 20, 00, 27]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 3
- Code(Zero) at (prev + 22, 1) to (start + 1, 12)
- Code(Zero) at (prev + 2, 9) to (start + 0, 16)
- Code(Zero) at (prev + 2, 9) to (start + 0, 16)
- Code(Zero) at (prev + 1, 15) to (start + 0, 22)
- Code(Zero) at (prev + 0, 32) to (start + 0, 39)

Function name: let_else_loop::_loop_either_way (unused)
Raw bytes (19): 0x[01, 01, 00, 03, 00, 0f, 01, 01, 14, 00, 01, 1c, 00, 23, 00, 01, 05, 00, 0c]
Expand Down
6 changes: 1 addition & 5 deletions tests/coverage/let_else_loop.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
LL| |// Variant using regular `if` instead of let-else.
LL| |// This doesn't trigger the original ICE, but might help detect regressions.
LL| 0|fn _if(cond: bool) {
LL| 0| if cond {
LL| 0| loop {}
LL| | } else {
LL| 0| loop {}
LL| | }
LL| 0| if cond { loop {} } else { loop {} }
LL| |}
LL| |
LL| |#[coverage(off)]
Expand Down
6 changes: 1 addition & 5 deletions tests/coverage/let_else_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ fn _loop_either_way(cond: bool) {
// Variant using regular `if` instead of let-else.
// This doesn't trigger the original ICE, but might help detect regressions.
fn _if(cond: bool) {
if cond {
loop {}
} else {
loop {}
}
if cond { loop {} } else { loop {} }
}

#[coverage(off)]
Expand Down
8 changes: 4 additions & 4 deletions tests/coverage/partial_eq.cov-map
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Function name: <partial_eq::Version>::new
Raw bytes (9): 0x[01, 01, 00, 01, 01, 0c, 05, 06, 06]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 0c, 05, 02, 06]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 12, 5) to (start + 6, 6)
- Code(Counter(0)) at (prev + 12, 5) to (start + 2, 6)

Function name: partial_eq::main
Raw bytes (9): 0x[01, 01, 00, 01, 01, 15, 01, 0a, 02]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 11, 01, 0a, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 21, 1) to (start + 10, 2)
- Code(Counter(0)) at (prev + 17, 1) to (start + 10, 2)

8 changes: 2 additions & 6 deletions tests/coverage/partial_eq.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
LL| |
LL| |impl Version {
LL| 2| pub fn new(major: usize, minor: usize, patch: usize) -> Self {
LL| 2| Self {
LL| 2| major,
LL| 2| minor,
LL| 2| patch,
LL| 2| }
LL| 2| Self { major, minor, patch }
LL| 2| }
LL| |}
LL| |
Expand All @@ -26,7 +22,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
8 changes: 2 additions & 6 deletions tests/coverage/partial_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ pub struct Version {

impl Version {
pub fn new(major: usize, minor: usize, patch: usize) -> Self {
Self {
major,
minor,
patch,
}
Self { major, minor, patch }
}
}

Expand All @@ -26,7 +22,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
Loading

0 comments on commit d1d8b3b

Please sign in to comment.