coverage: Allow #[coverage(..)]
on impl
and mod
These attributes apply to all enclosed functions/methods/closures, unless explicitly overridden by another coverage attribute.
This commit is contained in:
parent
3262611cc5
commit
7f37f8af5f
13 changed files with 253 additions and 170 deletions
42
tests/coverage/attr/impl.coverage
Normal file
42
tests/coverage/attr/impl.coverage
Normal file
|
@ -0,0 +1,42 @@
|
|||
LL| |#![feature(coverage_attribute)]
|
||||
LL| |//@ edition: 2021
|
||||
LL| |
|
||||
LL| |// Checks that `#[coverage(..)]` can be applied to impl and impl-trait blocks,
|
||||
LL| |// and is inherited by any enclosed functions.
|
||||
LL| |
|
||||
LL| |struct MyStruct;
|
||||
LL| |
|
||||
LL| |#[coverage(off)]
|
||||
LL| |impl MyStruct {
|
||||
LL| | fn off_inherit() {}
|
||||
LL| |
|
||||
LL| | #[coverage(on)]
|
||||
LL| 0| fn off_on() {}
|
||||
LL| |
|
||||
LL| | #[coverage(off)]
|
||||
LL| | fn off_off() {}
|
||||
LL| |}
|
||||
LL| |
|
||||
LL| |#[coverage(on)]
|
||||
LL| |impl MyStruct {
|
||||
LL| 0| fn on_inherit() {}
|
||||
LL| |
|
||||
LL| | #[coverage(on)]
|
||||
LL| 0| fn on_on() {}
|
||||
LL| |
|
||||
LL| | #[coverage(off)]
|
||||
LL| | fn on_off() {}
|
||||
LL| |}
|
||||
LL| |
|
||||
LL| |trait MyTrait {
|
||||
LL| | fn method();
|
||||
LL| |}
|
||||
LL| |
|
||||
LL| |#[coverage(off)]
|
||||
LL| |impl MyTrait for MyStruct {
|
||||
LL| | fn method() {}
|
||||
LL| |}
|
||||
LL| |
|
||||
LL| |#[coverage(off)]
|
||||
LL| |fn main() {}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue