Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reference annotations for the coverage attribute #134487

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions tests/coverage/attr/impl.cov-map
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
Function name: <impl::MyStruct>::off_on (unused)
Raw bytes (9): 0x[01, 01, 00, 01, 00, 0d, 05, 00, 13]
Raw bytes (9): 0x[01, 01, 00, 01, 00, 0e, 05, 00, 13]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Zero) at (prev + 13, 5) to (start + 0, 19)
- Code(Zero) at (prev + 14, 5) to (start + 0, 19)
Highest counter ID seen: (none)

Function name: <impl::MyStruct>::on_inherit (unused)
Raw bytes (9): 0x[01, 01, 00, 01, 00, 15, 05, 00, 17]
Raw bytes (9): 0x[01, 01, 00, 01, 00, 16, 05, 00, 17]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Zero) at (prev + 21, 5) to (start + 0, 23)
- Code(Zero) at (prev + 22, 5) to (start + 0, 23)
Highest counter ID seen: (none)

Function name: <impl::MyStruct>::on_on (unused)
Raw bytes (9): 0x[01, 01, 00, 01, 00, 18, 05, 00, 12]
Raw bytes (9): 0x[01, 01, 00, 01, 00, 19, 05, 00, 12]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Zero) at (prev + 24, 5) to (start + 0, 18)
- Code(Zero) at (prev + 25, 5) to (start + 0, 18)
Highest counter ID seen: (none)

1 change: 1 addition & 0 deletions tests/coverage/attr/impl.coverage
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
LL| |//@ edition: 2021
LL| |//@ reference: attributes.coverage.nesting
LL| |
LL| |// Checks that `#[coverage(..)]` can be applied to impl and impl-trait blocks,
LL| |// and is inherited by any enclosed functions.
Expand Down
1 change: 1 addition & 0 deletions tests/coverage/attr/impl.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ edition: 2021
//@ reference: attributes.coverage.nesting

// Checks that `#[coverage(..)]` can be applied to impl and impl-trait blocks,
// and is inherited by any enclosed functions.
Expand Down
12 changes: 6 additions & 6 deletions tests/coverage/attr/module.cov-map
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
Function name: module::off::on (unused)
Raw bytes (9): 0x[01, 01, 00, 01, 00, 0b, 05, 00, 0f]
Raw bytes (9): 0x[01, 01, 00, 01, 00, 0c, 05, 00, 0f]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Zero) at (prev + 11, 5) to (start + 0, 15)
- Code(Zero) at (prev + 12, 5) to (start + 0, 15)
Highest counter ID seen: (none)

Function name: module::on::inherit (unused)
Raw bytes (9): 0x[01, 01, 00, 01, 00, 13, 05, 00, 14]
Raw bytes (9): 0x[01, 01, 00, 01, 00, 14, 05, 00, 14]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Zero) at (prev + 19, 5) to (start + 0, 20)
- Code(Zero) at (prev + 20, 5) to (start + 0, 20)
Highest counter ID seen: (none)

Function name: module::on::on (unused)
Raw bytes (9): 0x[01, 01, 00, 01, 00, 16, 05, 00, 0f]
Raw bytes (9): 0x[01, 01, 00, 01, 00, 17, 05, 00, 0f]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Zero) at (prev + 22, 5) to (start + 0, 15)
- Code(Zero) at (prev + 23, 5) to (start + 0, 15)
Highest counter ID seen: (none)

1 change: 1 addition & 0 deletions tests/coverage/attr/module.coverage
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
LL| |//@ edition: 2021
LL| |//@ reference: attributes.coverage.nesting
LL| |
LL| |// Checks that `#[coverage(..)]` can be applied to modules, and is inherited
LL| |// by any enclosed functions.
Expand Down
1 change: 1 addition & 0 deletions tests/coverage/attr/module.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ edition: 2021
//@ reference: attributes.coverage.nesting

// Checks that `#[coverage(..)]` can be applied to modules, and is inherited
// by any enclosed functions.
Expand Down
8 changes: 4 additions & 4 deletions tests/coverage/attr/nested.cov-map
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
Function name: nested::closure_expr
Raw bytes (14): 0x[01, 01, 00, 02, 01, 3f, 01, 01, 0f, 01, 0b, 05, 01, 02]
Raw bytes (14): 0x[01, 01, 00, 02, 01, 40, 01, 01, 0f, 01, 0b, 05, 01, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 2
- Code(Counter(0)) at (prev + 63, 1) to (start + 1, 15)
- Code(Counter(0)) at (prev + 64, 1) to (start + 1, 15)
- Code(Counter(0)) at (prev + 11, 5) to (start + 1, 2)
Highest counter ID seen: c0

Function name: nested::closure_tail
Raw bytes (14): 0x[01, 01, 00, 02, 01, 4e, 01, 01, 0f, 01, 11, 05, 01, 02]
Raw bytes (14): 0x[01, 01, 00, 02, 01, 4f, 01, 01, 0f, 01, 11, 05, 01, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 2
- Code(Counter(0)) at (prev + 78, 1) to (start + 1, 15)
- Code(Counter(0)) at (prev + 79, 1) to (start + 1, 15)
- Code(Counter(0)) at (prev + 17, 5) to (start + 1, 2)
Highest counter ID seen: c0

1 change: 1 addition & 0 deletions tests/coverage/attr/nested.coverage
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
LL| |#![feature(stmt_expr_attributes)]
LL| |//@ edition: 2021
LL| |//@ reference: attributes.coverage.nesting
LL| |
LL| |// Demonstrates the interaction between #[coverage(off)] and various kinds of
LL| |// nested function.
Expand Down
1 change: 1 addition & 0 deletions tests/coverage/attr/nested.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![feature(stmt_expr_attributes)]
//@ edition: 2021
//@ reference: attributes.coverage.nesting

// Demonstrates the interaction between #[coverage(off)] and various kinds of
// nested function.
Expand Down
12 changes: 6 additions & 6 deletions tests/coverage/attr/off-on-sandwich.cov-map
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
Function name: off_on_sandwich::dense_a::dense_b
Raw bytes (14): 0x[01, 01, 00, 02, 01, 0e, 05, 02, 12, 01, 07, 05, 00, 06]
Raw bytes (14): 0x[01, 01, 00, 02, 01, 0f, 05, 02, 12, 01, 07, 05, 00, 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 + 14, 5) to (start + 2, 18)
- Code(Counter(0)) at (prev + 15, 5) to (start + 2, 18)
- Code(Counter(0)) at (prev + 7, 5) to (start + 0, 6)
Highest counter ID seen: c0

Function name: off_on_sandwich::sparse_a::sparse_b::sparse_c
Raw bytes (14): 0x[01, 01, 00, 02, 01, 20, 09, 02, 17, 01, 0b, 09, 00, 0a]
Raw bytes (14): 0x[01, 01, 00, 02, 01, 21, 09, 02, 17, 01, 0b, 09, 00, 0a]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 2
- Code(Counter(0)) at (prev + 32, 9) to (start + 2, 23)
- Code(Counter(0)) at (prev + 33, 9) to (start + 2, 23)
- Code(Counter(0)) at (prev + 11, 9) to (start + 0, 10)
Highest counter ID seen: c0

Function name: off_on_sandwich::sparse_a::sparse_b::sparse_c::sparse_d
Raw bytes (14): 0x[01, 01, 00, 02, 01, 23, 0d, 02, 1b, 01, 07, 0d, 00, 0e]
Raw bytes (14): 0x[01, 01, 00, 02, 01, 24, 0d, 02, 1b, 01, 07, 0d, 00, 0e]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 2
- Code(Counter(0)) at (prev + 35, 13) to (start + 2, 27)
- Code(Counter(0)) at (prev + 36, 13) to (start + 2, 27)
- Code(Counter(0)) at (prev + 7, 13) to (start + 0, 14)
Highest counter ID seen: c0

1 change: 1 addition & 0 deletions tests/coverage/attr/off-on-sandwich.coverage
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
LL| |//@ edition: 2021
LL| |//@ reference: attributes.coverage.nesting
LL| |
LL| |// Demonstrates the interaction of `#[coverage(off)]` and `#[coverage(on)]`
LL| |// in nested functions.
Expand Down
1 change: 1 addition & 0 deletions tests/coverage/attr/off-on-sandwich.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ edition: 2021
//@ reference: attributes.coverage.nesting

// Demonstrates the interaction of `#[coverage(off)]` and `#[coverage(on)]`
// in nested functions.
Expand Down
28 changes: 14 additions & 14 deletions tests/coverage/no_cov_crate.cov-map
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
Function name: no_cov_crate::add_coverage_1
Raw bytes (9): 0x[01, 01, 00, 01, 01, 13, 01, 02, 02]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 15, 01, 02, 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 + 19, 1) to (start + 2, 2)
- Code(Counter(0)) at (prev + 21, 1) to (start + 2, 2)
Highest counter ID seen: c0

Function name: no_cov_crate::add_coverage_2
Raw bytes (9): 0x[01, 01, 00, 01, 01, 17, 01, 02, 02]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 19, 01, 02, 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 + 23, 1) to (start + 2, 2)
- Code(Counter(0)) at (prev + 25, 1) to (start + 2, 2)
Highest counter ID seen: c0

Function name: no_cov_crate::add_coverage_not_called (unused)
Raw bytes (9): 0x[01, 01, 00, 01, 00, 1c, 01, 02, 02]
Raw bytes (9): 0x[01, 01, 00, 01, 00, 1e, 01, 02, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Zero) at (prev + 28, 1) to (start + 2, 2)
- Code(Zero) at (prev + 30, 1) to (start + 2, 2)
Highest counter ID seen: (none)

Function name: no_cov_crate::main
Raw bytes (9): 0x[01, 01, 00, 01, 01, 4c, 01, 0b, 02]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 4e, 01, 0b, 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 + 76, 1) to (start + 11, 2)
- Code(Counter(0)) at (prev + 78, 1) to (start + 11, 2)
Highest counter ID seen: c0

Function name: no_cov_crate::nested_fns::outer
Raw bytes (14): 0x[01, 01, 00, 02, 01, 30, 05, 02, 23, 01, 0c, 05, 00, 06]
Raw bytes (14): 0x[01, 01, 00, 02, 01, 32, 05, 02, 23, 01, 0c, 05, 00, 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 + 48, 5) to (start + 2, 35)
- Code(Counter(0)) at (prev + 50, 5) to (start + 2, 35)
- Code(Counter(0)) at (prev + 12, 5) to (start + 0, 6)
Highest counter ID seen: c0

Function name: no_cov_crate::nested_fns::outer_both_covered
Raw bytes (14): 0x[01, 01, 00, 02, 01, 3e, 05, 02, 17, 01, 0b, 05, 00, 06]
Raw bytes (14): 0x[01, 01, 00, 02, 01, 40, 05, 02, 17, 01, 0b, 05, 00, 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 + 62, 5) to (start + 2, 23)
- Code(Counter(0)) at (prev + 64, 5) to (start + 2, 23)
- Code(Counter(0)) at (prev + 11, 5) to (start + 0, 6)
Highest counter ID seen: c0

Function name: no_cov_crate::nested_fns::outer_both_covered::inner
Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 42, 09, 01, 17, 05, 01, 18, 02, 0e, 02, 02, 14, 02, 0e, 01, 03, 09, 00, 0a]
Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 44, 09, 01, 17, 05, 01, 18, 02, 0e, 02, 02, 14, 02, 0e, 01, 03, 09, 00, 0a]
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 + 66, 9) to (start + 1, 23)
- Code(Counter(0)) at (prev + 68, 9) to (start + 1, 23)
- Code(Counter(1)) at (prev + 1, 24) to (start + 2, 14)
- Code(Expression(0, Sub)) at (prev + 2, 20) to (start + 2, 14)
= (c0 - c1)
Expand Down
2 changes: 2 additions & 0 deletions tests/coverage/no_cov_crate.coverage
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
LL| |// Enables `coverage(off)` on the entire crate
LL| |//@ reference: attributes.coverage.intro
LL| |//@ reference: attributes.coverage.nesting
LL| |
LL| |#[coverage(off)]
LL| |fn do_not_add_coverage_1() {
Expand Down
2 changes: 2 additions & 0 deletions tests/coverage/no_cov_crate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Enables `coverage(off)` on the entire crate
//@ reference: attributes.coverage.intro
//@ reference: attributes.coverage.nesting

#[coverage(off)]
fn do_not_add_coverage_1() {
Expand Down
1 change: 1 addition & 0 deletions tests/ui/coverage-attr/bad-attr-ice.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//@ compile-flags: -Cinstrument-coverage
//@ needs-profiler-runtime
//@ reference: attributes.coverage.syntax

// Malformed `#[coverage(..)]` attributes should not cause an ICE when built
// with `-Cinstrument-coverage`.
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/coverage-attr/bad-attr-ice.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: malformed `coverage` attribute input
--> $DIR/bad-attr-ice.rs:8:1
--> $DIR/bad-attr-ice.rs:9:1
|
LL | #[coverage]
| ^^^^^^^^^^^
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/coverage-attr/bad-syntax.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//@ edition: 2021
//@ reference: attributes.coverage.syntax
//@ reference: attributes.coverage.duplicates

// Tests the error messages produced (or not produced) by various unusual
// uses of the `#[coverage(..)]` attribute.
Expand Down
Loading
Loading