diff --git a/tests/coverage/assert.cov-map b/tests/coverage/assert.cov-map
index 543ab89628281..4500eab355739 100644
--- a/tests/coverage/assert.cov-map
+++ b/tests/coverage/assert.cov-map
@@ -1,42 +1,72 @@
-Function name: assert::main
-Raw bytes (76): 0x[01, 01, 06, 05, 01, 05, 17, 01, 09, 05, 13, 17, 0d, 01, 09, 0c, 01, 09, 01, 00, 1c, 01, 01, 09, 00, 16, 01, 00, 19, 00, 1b, 05, 01, 0b, 00, 18, 02, 01, 0c, 00, 1a, 09, 00, 1b, 02, 0a, 06, 02, 13, 00, 20, 0d, 00, 21, 02, 0a, 0e, 02, 09, 00, 0a, 02, 01, 09, 00, 17, 01, 02, 05, 00, 0b, 01, 01, 01, 00, 02]
+Function name: assert::assert_a_plain
+Raw bytes (54): 0x[01, 01, 00, 0a, 01, 06, 01, 00, 25, 01, 01, 05, 00, 0c, 01, 00, 0d, 00, 10, 01, 00, 11, 00, 18, 05, 01, 05, 00, 0f, 09, 01, 05, 00, 0f, 15, 01, 05, 00, 14, 0d, 00, 15, 00, 18, 11, 00, 1f, 00, 25, 15, 01, 01, 00, 02]
Number of files: 1
- file 0 => $DIR/assert.rs
-Number of expressions: 6
-- expression 0 operands: lhs = Counter(1), rhs = Counter(0)
-- expression 1 operands: lhs = Counter(1), rhs = Expression(5, Add)
-- expression 2 operands: lhs = Counter(0), rhs = Counter(2)
-- expression 3 operands: lhs = Counter(1), rhs = Expression(4, Add)
-- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(3)
-- expression 5 operands: lhs = Counter(0), rhs = Counter(2)
-Number of file 0 mappings: 12
-- Code(Counter(0)) at (prev + 9, 1) to (start + 0, 28)
-- Code(Counter(0)) at (prev + 1, 9) to (start + 0, 22)
-- Code(Counter(0)) at (prev + 0, 25) to (start + 0, 27)
-- Code(Counter(1)) at (prev + 1, 11) to (start + 0, 24)
-- Code(Expression(0, Sub)) at (prev + 1, 12) to (start + 0, 26)
- = (c1 - c0)
-- Code(Counter(2)) at (prev + 0, 27) to (start + 2, 10)
-- Code(Expression(1, Sub)) at (prev + 2, 19) to (start + 0, 32)
- = (c1 - (c0 + c2))
-- Code(Counter(3)) at (prev + 0, 33) to (start + 2, 10)
-- Code(Expression(3, Sub)) at (prev + 2, 9) to (start + 0, 10)
- = (c1 - ((c0 + c2) + c3))
-- Code(Expression(0, Sub)) at (prev + 1, 9) to (start + 0, 23)
- = (c1 - c0)
-- Code(Counter(0)) at (prev + 2, 5) to (start + 0, 11)
-- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2)
-Highest counter ID seen: c3
+Number of expressions: 0
+Number of file 0 mappings: 10
+- Code(Counter(0)) at (prev + 6, 1) to (start + 0, 37)
+- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 12)
+- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 16)
+- Code(Counter(0)) at (prev + 0, 17) to (start + 0, 24)
+- Code(Counter(1)) at (prev + 1, 5) to (start + 0, 15)
+- Code(Counter(2)) at (prev + 1, 5) to (start + 0, 15)
+- Code(Counter(5)) at (prev + 1, 5) to (start + 0, 20)
+- Code(Counter(3)) at (prev + 0, 21) to (start + 0, 24)
+- Code(Counter(4)) at (prev + 0, 31) to (start + 0, 37)
+- Code(Counter(5)) at (prev + 1, 1) to (start + 0, 2)
+Highest counter ID seen: c5
+
+Function name: assert::assert_b_message
+Raw bytes (54): 0x[01, 01, 00, 0a, 01, 0d, 01, 00, 27, 01, 01, 05, 00, 0c, 01, 00, 0d, 00, 10, 01, 00, 11, 00, 18, 05, 01, 05, 00, 0f, 09, 01, 05, 00, 0f, 15, 01, 05, 00, 14, 0d, 00, 15, 00, 18, 11, 00, 1f, 00, 25, 15, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => $DIR/assert.rs
+Number of expressions: 0
+Number of file 0 mappings: 10
+- Code(Counter(0)) at (prev + 13, 1) to (start + 0, 39)
+- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 12)
+- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 16)
+- Code(Counter(0)) at (prev + 0, 17) to (start + 0, 24)
+- Code(Counter(1)) at (prev + 1, 5) to (start + 0, 15)
+- Code(Counter(2)) at (prev + 1, 5) to (start + 0, 15)
+- Code(Counter(5)) at (prev + 1, 5) to (start + 0, 20)
+- Code(Counter(3)) at (prev + 0, 21) to (start + 0, 24)
+- Code(Counter(4)) at (prev + 0, 31) to (start + 0, 37)
+- Code(Counter(5)) at (prev + 1, 1) to (start + 0, 2)
+Highest counter ID seen: c5
+
+Function name: assert::assert_c_format_inline
+Raw bytes (54): 0x[01, 01, 00, 0a, 01, 14, 01, 00, 38, 01, 01, 05, 00, 0c, 01, 00, 0d, 00, 10, 01, 00, 11, 00, 18, 05, 01, 05, 00, 0f, 09, 01, 05, 00, 0f, 15, 01, 05, 00, 14, 0d, 00, 15, 00, 18, 11, 00, 1f, 00, 25, 15, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => $DIR/assert.rs
+Number of expressions: 0
+Number of file 0 mappings: 10
+- Code(Counter(0)) at (prev + 20, 1) to (start + 0, 56)
+- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 12)
+- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 16)
+- Code(Counter(0)) at (prev + 0, 17) to (start + 0, 24)
+- Code(Counter(1)) at (prev + 1, 5) to (start + 0, 15)
+- Code(Counter(2)) at (prev + 1, 5) to (start + 0, 15)
+- Code(Counter(5)) at (prev + 1, 5) to (start + 0, 20)
+- Code(Counter(3)) at (prev + 0, 21) to (start + 0, 24)
+- Code(Counter(4)) at (prev + 0, 31) to (start + 0, 37)
+- Code(Counter(5)) at (prev + 1, 1) to (start + 0, 2)
+Highest counter ID seen: c5
-Function name: assert::might_fail_assert
-Raw bytes (24): 0x[01, 01, 00, 04, 01, 04, 01, 00, 28, 01, 01, 05, 00, 0d, 01, 01, 05, 00, 0f, 05, 01, 01, 00, 02]
+Function name: assert::assert_d_format_arg
+Raw bytes (54): 0x[01, 01, 00, 0a, 01, 1b, 01, 00, 35, 01, 01, 05, 00, 0c, 01, 00, 0d, 00, 10, 01, 00, 11, 00, 18, 05, 01, 05, 00, 0f, 09, 01, 05, 00, 0f, 15, 01, 05, 00, 14, 0d, 00, 15, 00, 18, 11, 00, 1f, 00, 25, 15, 01, 01, 00, 02]
Number of files: 1
- file 0 => $DIR/assert.rs
Number of expressions: 0
-Number of file 0 mappings: 4
-- Code(Counter(0)) at (prev + 4, 1) to (start + 0, 40)
-- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13)
-- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 15)
-- Code(Counter(1)) at (prev + 1, 1) to (start + 0, 2)
-Highest counter ID seen: c1
+Number of file 0 mappings: 10
+- Code(Counter(0)) at (prev + 27, 1) to (start + 0, 53)
+- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 12)
+- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 16)
+- Code(Counter(0)) at (prev + 0, 17) to (start + 0, 24)
+- Code(Counter(1)) at (prev + 1, 5) to (start + 0, 15)
+- Code(Counter(2)) at (prev + 1, 5) to (start + 0, 15)
+- Code(Counter(5)) at (prev + 1, 5) to (start + 0, 20)
+- Code(Counter(3)) at (prev + 0, 21) to (start + 0, 24)
+- Code(Counter(4)) at (prev + 0, 31) to (start + 0, 37)
+- Code(Counter(5)) at (prev + 1, 1) to (start + 0, 2)
+Highest counter ID seen: c5
diff --git a/tests/coverage/assert.coverage b/tests/coverage/assert.coverage
index 29a5b48c0566a..d9171fd705c99 100644
--- a/tests/coverage/assert.coverage
+++ b/tests/coverage/assert.coverage
@@ -1,33 +1,42 @@
- LL| |#![allow(unused_assignments)]
- LL| |//@ failure-status: 101
+ LL| |#![feature(coverage_attribute)]
+ LL| |//@ edition: 2024
LL| |
- LL| 4|fn might_fail_assert(one_plus_one: u32) {
- LL| 4| println!("does 1 + 1 = {}?", one_plus_one);
- LL| 4| assert_eq!(1 + 1, one_plus_one, "the argument was wrong");
- LL| 3|}
+ LL| |use core::assert_matches;
LL| |
- LL| 1|fn main() -> Result<(), u8> {
- LL| 1| let mut countdown = 10;
- LL| 10| while countdown > 0 {
- LL| 9| if countdown == 1 {
- LL| 1| might_fail_assert(3);
- LL| 8| } else if countdown < 5 {
- LL| 3| might_fail_assert(2);
- LL| 5| }
- LL| 9| countdown -= 1;
- LL| | }
- LL| 1| Ok(())
+ LL| 1|fn assert_a_plain(opt: Option<&str>) {
+ LL| 1| assert!(opt.is_some());
+ LL| 1| assert_eq!(opt, Some("true"));
+ LL| 1| assert_ne!(opt, None);
+ LL| 1| assert_matches!(opt, Some("true"));
LL| 1|}
LL| |
- LL| |// Notes:
- LL| |// 1. Compare this program and its coverage results to those of the very similar test
- LL| |// `panic_unwind.rs`, and similar tests `abort.rs` and `try_error_result.rs`.
- LL| |// 2. This test confirms the coverage generated when a program passes or fails an `assert!()` or
- LL| |// related `assert_*!()` macro.
- LL| |// 3. Notably, the `assert` macros *do not* generate `TerminatorKind::Assert`. The macros produce
- LL| |// conditional expressions, `TerminatorKind::SwitchInt` branches, and a possible call to
- LL| |// `begin_panic_fmt()` (that begins a panic unwind, if the assertion test fails).
- LL| |// 4. `TerminatorKind::Assert` is, however, also present in the MIR generated for this test
- LL| |// (and in many other coverage tests). The `Assert` terminator is typically generated by the
- LL| |// Rust compiler to check for runtime failures, such as numeric overflows.
+ LL| 1|fn assert_b_message(opt: Option<&str>) {
+ LL| 1| assert!(opt.is_some(), "message");
+ LL| 1| assert_eq!(opt, Some("true"), "message");
+ LL| 1| assert_ne!(opt, None, "message");
+ LL| 1| assert_matches!(opt, Some("true"), "message");
+ LL| 1|}
+ LL| |
+ LL| 1|fn assert_c_format_inline(opt: Option<&str>, msg: &str) {
+ LL| 1| assert!(opt.is_some(), "message: {msg}");
+ LL| 1| assert_eq!(opt, Some("true"), "message: {msg}");
+ LL| 1| assert_ne!(opt, None, "message: {msg}");
+ LL| 1| assert_matches!(opt, Some("true"), "message: {msg}");
+ LL| 1|}
+ LL| |
+ LL| 1|fn assert_d_format_arg(opt: Option<&str>, msg: &str) {
+ LL| 1| assert!(opt.is_some(), "message: {}", msg);
+ LL| 1| assert_eq!(opt, Some("true"), "message: {}", msg);
+ LL| 1| assert_ne!(opt, None, "message: {}", msg);
+ LL| 1| assert_matches!(opt, Some("true"), "message: {}", msg);
+ LL| 1|}
+ LL| |
+ LL| |#[coverage(off)]
+ LL| |fn main() {
+ LL| | let opt = core::hint::black_box(Some("true"));
+ LL| | assert_a_plain(opt);
+ LL| | assert_b_message(opt);
+ LL| | assert_c_format_inline(opt, "message");
+ LL| | assert_d_format_arg(opt, "message");
+ LL| |}
diff --git a/tests/coverage/assert.rs b/tests/coverage/assert.rs
index 30d511f8f7a89..9c3151ba4ce17 100644
--- a/tests/coverage/assert.rs
+++ b/tests/coverage/assert.rs
@@ -1,32 +1,41 @@
-#![allow(unused_assignments)]
-//@ failure-status: 101
+#![feature(coverage_attribute)]
+//@ edition: 2024
-fn might_fail_assert(one_plus_one: u32) {
- println!("does 1 + 1 = {}?", one_plus_one);
- assert_eq!(1 + 1, one_plus_one, "the argument was wrong");
+use core::assert_matches;
+
+fn assert_a_plain(opt: Option<&str>) {
+ assert!(opt.is_some());
+ assert_eq!(opt, Some("true"));
+ assert_ne!(opt, None);
+ assert_matches!(opt, Some("true"));
+}
+
+fn assert_b_message(opt: Option<&str>) {
+ assert!(opt.is_some(), "message");
+ assert_eq!(opt, Some("true"), "message");
+ assert_ne!(opt, None, "message");
+ assert_matches!(opt, Some("true"), "message");
}
-fn main() -> Result<(), u8> {
- let mut countdown = 10;
- while countdown > 0 {
- if countdown == 1 {
- might_fail_assert(3);
- } else if countdown < 5 {
- might_fail_assert(2);
- }
- countdown -= 1;
- }
- Ok(())
+fn assert_c_format_inline(opt: Option<&str>, msg: &str) {
+ assert!(opt.is_some(), "message: {msg}");
+ assert_eq!(opt, Some("true"), "message: {msg}");
+ assert_ne!(opt, None, "message: {msg}");
+ assert_matches!(opt, Some("true"), "message: {msg}");
}
-// Notes:
-// 1. Compare this program and its coverage results to those of the very similar test
-// `panic_unwind.rs`, and similar tests `abort.rs` and `try_error_result.rs`.
-// 2. This test confirms the coverage generated when a program passes or fails an `assert!()` or
-// related `assert_*!()` macro.
-// 3. Notably, the `assert` macros *do not* generate `TerminatorKind::Assert`. The macros produce
-// conditional expressions, `TerminatorKind::SwitchInt` branches, and a possible call to
-// `begin_panic_fmt()` (that begins a panic unwind, if the assertion test fails).
-// 4. `TerminatorKind::Assert` is, however, also present in the MIR generated for this test
-// (and in many other coverage tests). The `Assert` terminator is typically generated by the
-// Rust compiler to check for runtime failures, such as numeric overflows.
+fn assert_d_format_arg(opt: Option<&str>, msg: &str) {
+ assert!(opt.is_some(), "message: {}", msg);
+ assert_eq!(opt, Some("true"), "message: {}", msg);
+ assert_ne!(opt, None, "message: {}", msg);
+ assert_matches!(opt, Some("true"), "message: {}", msg);
+}
+
+#[coverage(off)]
+fn main() {
+ let opt = core::hint::black_box(Some("true"));
+ assert_a_plain(opt);
+ assert_b_message(opt);
+ assert_c_format_inline(opt, "message");
+ assert_d_format_arg(opt, "message");
+}
diff --git a/tests/coverage/async.cov-map b/tests/coverage/async/async.cov-map
similarity index 100%
rename from tests/coverage/async.cov-map
rename to tests/coverage/async/async.cov-map
diff --git a/tests/coverage/async.coverage b/tests/coverage/async/async.coverage
similarity index 100%
rename from tests/coverage/async.coverage
rename to tests/coverage/async/async.coverage
diff --git a/tests/coverage/async.rs b/tests/coverage/async/async.rs
similarity index 100%
rename from tests/coverage/async.rs
rename to tests/coverage/async/async.rs
diff --git a/tests/coverage/async2.cov-map b/tests/coverage/async/async2.cov-map
similarity index 100%
rename from tests/coverage/async2.cov-map
rename to tests/coverage/async/async2.cov-map
diff --git a/tests/coverage/async2.coverage b/tests/coverage/async/async2.coverage
similarity index 100%
rename from tests/coverage/async2.coverage
rename to tests/coverage/async/async2.coverage
diff --git a/tests/coverage/async2.rs b/tests/coverage/async/async2.rs
similarity index 100%
rename from tests/coverage/async2.rs
rename to tests/coverage/async/async2.rs
diff --git a/tests/coverage/async_block.cov-map b/tests/coverage/async/async_block.cov-map
similarity index 100%
rename from tests/coverage/async_block.cov-map
rename to tests/coverage/async/async_block.cov-map
diff --git a/tests/coverage/async_block.coverage b/tests/coverage/async/async_block.coverage
similarity index 100%
rename from tests/coverage/async_block.coverage
rename to tests/coverage/async/async_block.coverage
diff --git a/tests/coverage/async_block.rs b/tests/coverage/async/async_block.rs
similarity index 100%
rename from tests/coverage/async_block.rs
rename to tests/coverage/async/async_block.rs
diff --git a/tests/coverage/async_closure.cov-map b/tests/coverage/async/async_closure.cov-map
similarity index 100%
rename from tests/coverage/async_closure.cov-map
rename to tests/coverage/async/async_closure.cov-map
diff --git a/tests/coverage/async_closure.coverage b/tests/coverage/async/async_closure.coverage
similarity index 100%
rename from tests/coverage/async_closure.coverage
rename to tests/coverage/async/async_closure.coverage
diff --git a/tests/coverage/async_closure.rs b/tests/coverage/async/async_closure.rs
similarity index 100%
rename from tests/coverage/async_closure.rs
rename to tests/coverage/async/async_closure.rs
diff --git a/tests/coverage/async_closure2.cov-map b/tests/coverage/async/async_closure2.cov-map
similarity index 100%
rename from tests/coverage/async_closure2.cov-map
rename to tests/coverage/async/async_closure2.cov-map
diff --git a/tests/coverage/async_closure2.coverage b/tests/coverage/async/async_closure2.coverage
similarity index 100%
rename from tests/coverage/async_closure2.coverage
rename to tests/coverage/async/async_closure2.coverage
diff --git a/tests/coverage/async_closure2.rs b/tests/coverage/async/async_closure2.rs
similarity index 100%
rename from tests/coverage/async_closure2.rs
rename to tests/coverage/async/async_closure2.rs
diff --git a/tests/coverage/auxiliary/executor.rs b/tests/coverage/async/auxiliary/executor.rs
similarity index 100%
rename from tests/coverage/auxiliary/executor.rs
rename to tests/coverage/async/auxiliary/executor.rs
diff --git a/tests/coverage/await_ready.cov-map b/tests/coverage/async/await_ready.cov-map
similarity index 100%
rename from tests/coverage/await_ready.cov-map
rename to tests/coverage/async/await_ready.cov-map
diff --git a/tests/coverage/await_ready.coverage b/tests/coverage/async/await_ready.coverage
similarity index 100%
rename from tests/coverage/await_ready.coverage
rename to tests/coverage/async/await_ready.coverage
diff --git a/tests/coverage/await_ready.rs b/tests/coverage/async/await_ready.rs
similarity index 100%
rename from tests/coverage/await_ready.rs
rename to tests/coverage/async/await_ready.rs
diff --git a/tests/coverage/closure_macro_async.cov-map b/tests/coverage/async/closure_macro_async.cov-map
similarity index 100%
rename from tests/coverage/closure_macro_async.cov-map
rename to tests/coverage/async/closure_macro_async.cov-map
diff --git a/tests/coverage/closure_macro_async.coverage b/tests/coverage/async/closure_macro_async.coverage
similarity index 100%
rename from tests/coverage/closure_macro_async.coverage
rename to tests/coverage/async/closure_macro_async.coverage
diff --git a/tests/coverage/closure_macro_async.rs b/tests/coverage/async/closure_macro_async.rs
similarity index 100%
rename from tests/coverage/closure_macro_async.rs
rename to tests/coverage/async/closure_macro_async.rs
diff --git a/tests/coverage/call-method.cov-map b/tests/coverage/call-method.cov-map
new file mode 100644
index 0000000000000..534cc4b6a58af
--- /dev/null
+++ b/tests/coverage/call-method.cov-map
@@ -0,0 +1,19 @@
+Function name: call_method::call_method
+Raw bytes (59): 0x[01, 01, 00, 0b, 01, 08, 01, 00, 11, 01, 01, 09, 00, 0e, 01, 00, 11, 00, 16, 01, 02, 05, 00, 0a, 01, 02, 09, 00, 0f, 01, 02, 0d, 00, 12, 01, 04, 05, 05, 0a, 01, 00, 05, 00, 0a, 01, 07, 09, 00, 0f, 01, 02, 0d, 00, 12, 01, 03, 01, 00, 02]
+Number of files: 1
+- file 0 => $DIR/call-method.rs
+Number of expressions: 0
+Number of file 0 mappings: 11
+- Code(Counter(0)) at (prev + 8, 1) to (start + 0, 17)
+- Code(Counter(0)) at (prev + 1, 9) to (start + 0, 14)
+- Code(Counter(0)) at (prev + 0, 17) to (start + 0, 22)
+- Code(Counter(0)) at (prev + 2, 5) to (start + 0, 10)
+- Code(Counter(0)) at (prev + 2, 9) to (start + 0, 15)
+- Code(Counter(0)) at (prev + 2, 13) to (start + 0, 18)
+- Code(Counter(0)) at (prev + 4, 5) to (start + 5, 10)
+- Code(Counter(0)) at (prev + 0, 5) to (start + 0, 10)
+- Code(Counter(0)) at (prev + 7, 9) to (start + 0, 15)
+- Code(Counter(0)) at (prev + 2, 13) to (start + 0, 18)
+- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2)
+Highest counter ID seen: c0
+
diff --git a/tests/coverage/call-method.coverage b/tests/coverage/call-method.coverage
new file mode 100644
index 0000000000000..afcdb0adc7b73
--- /dev/null
+++ b/tests/coverage/call-method.coverage
@@ -0,0 +1,46 @@
+ LL| |#![feature(coverage_attribute)]
+ LL| |//@ edition: 2024
+ LL| |//@ min-llvm-version: 23
+ LL| |
+ LL| |// Basic test for method calls and chained method calls.
+ LL| |
+ LL| |#[rustfmt::skip]
+ LL| 1|fn call_method() {
+ LL| 1| let thing = Thing;
+ LL| |
+ LL| 1| thing
+ LL| | .
+ LL| 1| method
+ LL| | (
+ LL| 1| "arg"
+ LL| | )
+ LL| | ;
+ LL| |
+ LL| 1| thing
+ LL| 1| .
+ LL| 1| method
+ LL| 1| (
+ LL| 1| "arg"
+ LL| 1| )
+ LL| | .
+ LL| 1| method
+ LL| | (
+ LL| 1| "arg"
+ LL| | )
+ LL| | ;
+ LL| 1|}
+ LL| |
+ LL| |struct Thing;
+ LL| |
+ LL| |#[coverage(off)]
+ LL| |impl Thing {
+ LL| | fn method(&self, _arg: &str) -> &Self {
+ LL| | self
+ LL| | }
+ LL| |}
+ LL| |
+ LL| |#[coverage(off)]
+ LL| |fn main() {
+ LL| | call_method();
+ LL| |}
+
diff --git a/tests/coverage/call-method.rs b/tests/coverage/call-method.rs
new file mode 100644
index 0000000000000..42b753503331b
--- /dev/null
+++ b/tests/coverage/call-method.rs
@@ -0,0 +1,45 @@
+#![feature(coverage_attribute)]
+//@ edition: 2024
+//@ min-llvm-version: 23
+
+// Basic test for method calls and chained method calls.
+
+#[rustfmt::skip]
+fn call_method() {
+ let thing = Thing;
+
+ thing
+ .
+ method
+ (
+ "arg"
+ )
+ ;
+
+ thing
+ .
+ method
+ (
+ "arg"
+ )
+ .
+ method
+ (
+ "arg"
+ )
+ ;
+}
+
+struct Thing;
+
+#[coverage(off)]
+impl Thing {
+ fn method(&self, _arg: &str) -> &Self {
+ self
+ }
+}
+
+#[coverage(off)]
+fn main() {
+ call_method();
+}
diff --git a/tests/coverage/for.many.coverage b/tests/coverage/for.many.coverage
new file mode 100644
index 0000000000000..c6908b64cd615
--- /dev/null
+++ b/tests/coverage/for.many.coverage
@@ -0,0 +1,39 @@
+ LL| |#![feature(coverage_attribute)]
+ LL| |//@ edition: 2024
+ LL| |//@ revisions: zero one many
+ LL| |//@[one] ignore-coverage-map
+ LL| |//@[many] ignore-coverage-map
+ LL| |
+ LL| |// Basic test of `for` loops.
+ LL| |
+ LL| 1|fn for_loop(items: &[&str]) {
+ LL| 1| say("hello");
+ LL| |
+ LL| 3| for item in items {
+ ^1
+ LL| 3| say(item);
+ LL| 3| }
+ LL| |
+ LL| 3| for item in items {
+ ^1
+ LL| 3| say(item)
+ LL| | }
+ LL| |
+ LL| 1| say("goodbye");
+ LL| 1|}
+ LL| |
+ LL| |#[coverage(off)]
+ LL| |fn main() {
+ LL| | let items = cfg_select!(
+ LL| | zero => &[],
+ LL| | one => &["one"],
+ LL| | many => &["one", "two", "three"],
+ LL| | );
+ LL| | for_loop(items);
+ LL| |}
+ LL| |
+ LL| |#[coverage(off)]
+ LL| |fn say(msg: &str) {
+ LL| | println!("{msg}");
+ LL| |}
+
diff --git a/tests/coverage/for.one.coverage b/tests/coverage/for.one.coverage
new file mode 100644
index 0000000000000..285d379c526f9
--- /dev/null
+++ b/tests/coverage/for.one.coverage
@@ -0,0 +1,37 @@
+ LL| |#![feature(coverage_attribute)]
+ LL| |//@ edition: 2024
+ LL| |//@ revisions: zero one many
+ LL| |//@[one] ignore-coverage-map
+ LL| |//@[many] ignore-coverage-map
+ LL| |
+ LL| |// Basic test of `for` loops.
+ LL| |
+ LL| 1|fn for_loop(items: &[&str]) {
+ LL| 1| say("hello");
+ LL| |
+ LL| 1| for item in items {
+ LL| 1| say(item);
+ LL| 1| }
+ LL| |
+ LL| 1| for item in items {
+ LL| 1| say(item)
+ LL| | }
+ LL| |
+ LL| 1| say("goodbye");
+ LL| 1|}
+ LL| |
+ LL| |#[coverage(off)]
+ LL| |fn main() {
+ LL| | let items = cfg_select!(
+ LL| | zero => &[],
+ LL| | one => &["one"],
+ LL| | many => &["one", "two", "three"],
+ LL| | );
+ LL| | for_loop(items);
+ LL| |}
+ LL| |
+ LL| |#[coverage(off)]
+ LL| |fn say(msg: &str) {
+ LL| | println!("{msg}");
+ LL| |}
+
diff --git a/tests/coverage/for.rs b/tests/coverage/for.rs
new file mode 100644
index 0000000000000..55a2cfc2c18d2
--- /dev/null
+++ b/tests/coverage/for.rs
@@ -0,0 +1,36 @@
+#![feature(coverage_attribute)]
+//@ edition: 2024
+//@ revisions: zero one many
+//@[one] ignore-coverage-map
+//@[many] ignore-coverage-map
+
+// Basic test of `for` loops.
+
+fn for_loop(items: &[&str]) {
+ say("hello");
+
+ for item in items {
+ say(item);
+ }
+
+ for item in items {
+ say(item)
+ }
+
+ say("goodbye");
+}
+
+#[coverage(off)]
+fn main() {
+ let items = cfg_select!(
+ zero => &[],
+ one => &["one"],
+ many => &["one", "two", "three"],
+ );
+ for_loop(items);
+}
+
+#[coverage(off)]
+fn say(msg: &str) {
+ println!("{msg}");
+}
diff --git a/tests/coverage/for.zero.cov-map b/tests/coverage/for.zero.cov-map
new file mode 100644
index 0000000000000..4ac461b85719f
--- /dev/null
+++ b/tests/coverage/for.zero.cov-map
@@ -0,0 +1,30 @@
+Function name: for::for_loop
+Raw bytes (77): 0x[01, 01, 04, 05, 01, 09, 01, 09, 01, 09, 01, 0d, 01, 09, 01, 00, 1c, 01, 01, 05, 00, 08, 01, 00, 09, 00, 10, 02, 02, 09, 00, 0d, 01, 00, 11, 00, 16, 02, 00, 17, 02, 06, 0e, 04, 09, 00, 0d, 01, 00, 11, 00, 16, 0e, 01, 09, 00, 0c, 0e, 00, 0d, 00, 11, 01, 03, 05, 00, 08, 01, 00, 09, 00, 12, 01, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => $DIR/for.rs
+Number of expressions: 4
+- expression 0 operands: lhs = Counter(1), rhs = Counter(0)
+- expression 1 operands: lhs = Counter(2), rhs = Counter(0)
+- expression 2 operands: lhs = Counter(2), rhs = Counter(0)
+- expression 3 operands: lhs = Counter(2), rhs = Counter(0)
+Number of file 0 mappings: 13
+- Code(Counter(0)) at (prev + 9, 1) to (start + 0, 28)
+- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 8)
+- Code(Counter(0)) at (prev + 0, 9) to (start + 0, 16)
+- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 13)
+ = (c1 - c0)
+- Code(Counter(0)) at (prev + 0, 17) to (start + 0, 22)
+- Code(Expression(0, Sub)) at (prev + 0, 23) to (start + 2, 6)
+ = (c1 - c0)
+- Code(Expression(3, Sub)) at (prev + 4, 9) to (start + 0, 13)
+ = (c2 - c0)
+- Code(Counter(0)) at (prev + 0, 17) to (start + 0, 22)
+- Code(Expression(3, Sub)) at (prev + 1, 9) to (start + 0, 12)
+ = (c2 - c0)
+- Code(Expression(3, Sub)) at (prev + 0, 13) to (start + 0, 17)
+ = (c2 - c0)
+- Code(Counter(0)) at (prev + 3, 5) to (start + 0, 8)
+- Code(Counter(0)) at (prev + 0, 9) to (start + 0, 18)
+- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2)
+Highest counter ID seen: c0
+
diff --git a/tests/coverage/for.zero.coverage b/tests/coverage/for.zero.coverage
new file mode 100644
index 0000000000000..9376a371275d4
--- /dev/null
+++ b/tests/coverage/for.zero.coverage
@@ -0,0 +1,39 @@
+ LL| |#![feature(coverage_attribute)]
+ LL| |//@ edition: 2024
+ LL| |//@ revisions: zero one many
+ LL| |//@[one] ignore-coverage-map
+ LL| |//@[many] ignore-coverage-map
+ LL| |
+ LL| |// Basic test of `for` loops.
+ LL| |
+ LL| 1|fn for_loop(items: &[&str]) {
+ LL| 1| say("hello");
+ LL| |
+ LL| 1| for item in items {
+ ^0
+ LL| 0| say(item);
+ LL| 0| }
+ LL| |
+ LL| 1| for item in items {
+ ^0
+ LL| 0| say(item)
+ LL| | }
+ LL| |
+ LL| 1| say("goodbye");
+ LL| 1|}
+ LL| |
+ LL| |#[coverage(off)]
+ LL| |fn main() {
+ LL| | let items = cfg_select!(
+ LL| | zero => &[],
+ LL| | one => &["one"],
+ LL| | many => &["one", "two", "three"],
+ LL| | );
+ LL| | for_loop(items);
+ LL| |}
+ LL| |
+ LL| |#[coverage(off)]
+ LL| |fn say(msg: &str) {
+ LL| | println!("{msg}");
+ LL| |}
+
diff --git a/tests/coverage/if-let-chain.none.cov-map b/tests/coverage/if-let-chain.none.cov-map
new file mode 100644
index 0000000000000..9626b6cc8553b
--- /dev/null
+++ b/tests/coverage/if-let-chain.none.cov-map
@@ -0,0 +1,40 @@
+Function name: if_let_chain::if_let_chain
+Raw bytes (105): 0x[01, 01, 08, 09, 05, 0b, 09, 01, 05, 11, 0d, 11, 0d, 11, 0d, 1f, 11, 01, 0d, 11, 01, 09, 01, 00, 33, 09, 01, 11, 00, 18, 01, 00, 1c, 00, 27, 02, 01, 15, 00, 18, 09, 00, 1c, 00, 23, 02, 01, 05, 02, 06, 06, 02, 05, 00, 06, 11, 02, 11, 00, 18, 01, 00, 1c, 00, 27, 16, 01, 15, 00, 18, 11, 00, 1c, 00, 23, 16, 02, 09, 00, 0c, 16, 00, 0d, 00, 10, 1a, 01, 05, 00, 06, 01, 02, 05, 00, 08, 01, 00, 09, 00, 12, 01, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => $DIR/if-let-chain.rs
+Number of expressions: 8
+- expression 0 operands: lhs = Counter(2), rhs = Counter(1)
+- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(2)
+- expression 2 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 3 operands: lhs = Counter(4), rhs = Counter(3)
+- expression 4 operands: lhs = Counter(4), rhs = Counter(3)
+- expression 5 operands: lhs = Counter(4), rhs = Counter(3)
+- expression 6 operands: lhs = Expression(7, Add), rhs = Counter(4)
+- expression 7 operands: lhs = Counter(0), rhs = Counter(3)
+Number of file 0 mappings: 17
+- Code(Counter(0)) at (prev + 9, 1) to (start + 0, 51)
+- Code(Counter(2)) at (prev + 1, 17) to (start + 0, 24)
+- Code(Counter(0)) at (prev + 0, 28) to (start + 0, 39)
+- Code(Expression(0, Sub)) at (prev + 1, 21) to (start + 0, 24)
+ = (c2 - c1)
+- Code(Counter(2)) at (prev + 0, 28) to (start + 0, 35)
+- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 2, 6)
+ = (c2 - c1)
+- Code(Expression(1, Sub)) at (prev + 2, 5) to (start + 0, 6)
+ = ((c0 + c1) - c2)
+- Code(Counter(4)) at (prev + 2, 17) to (start + 0, 24)
+- Code(Counter(0)) at (prev + 0, 28) to (start + 0, 39)
+- Code(Expression(5, Sub)) at (prev + 1, 21) to (start + 0, 24)
+ = (c4 - c3)
+- Code(Counter(4)) at (prev + 0, 28) to (start + 0, 35)
+- Code(Expression(5, Sub)) at (prev + 2, 9) to (start + 0, 12)
+ = (c4 - c3)
+- Code(Expression(5, Sub)) at (prev + 0, 13) to (start + 0, 16)
+ = (c4 - c3)
+- Code(Expression(6, Sub)) at (prev + 1, 5) to (start + 0, 6)
+ = ((c0 + c3) - c4)
+- Code(Counter(0)) at (prev + 2, 5) to (start + 0, 8)
+- Code(Counter(0)) at (prev + 0, 9) to (start + 0, 18)
+- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2)
+Highest counter ID seen: c4
+
diff --git a/tests/coverage/if-let-chain.none.coverage b/tests/coverage/if-let-chain.none.coverage
new file mode 100644
index 0000000000000..a5aba75201ead
--- /dev/null
+++ b/tests/coverage/if-let-chain.none.coverage
@@ -0,0 +1,41 @@
+ LL| |#![feature(coverage_attribute)]
+ LL| |//@ edition: 2024
+ LL| |//@ revisions: none one two
+ LL| |//@[one] ignore-coverage-map
+ LL| |//@[two] ignore-coverage-map
+ LL| |
+ LL| |// Basic test for if-let chains.
+ LL| |
+ LL| 1|fn if_let_chain(opt_opt_msg: Option