diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2024-06-21 21:59:02 +1000 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2024-06-26 10:08:05 +1000 |
| commit | 7f37f8af5f067e0f4f8d14adb7d76f013e3c4118 (patch) | |
| tree | bf626edd2d408b287ad5f0ad522162dcdc09c431 /tests/coverage/attr/impl.rs | |
| parent | 3262611cc5db7ce83dee4268fb1901311b24e5fc (diff) | |
| download | rust-7f37f8af5f067e0f4f8d14adb7d76f013e3c4118.tar.gz rust-7f37f8af5f067e0f4f8d14adb7d76f013e3c4118.zip | |
coverage: Allow `#[coverage(..)]` on `impl` and `mod`
These attributes apply to all enclosed functions/methods/closures, unless explicitly overridden by another coverage attribute.
Diffstat (limited to 'tests/coverage/attr/impl.rs')
| -rw-r--r-- | tests/coverage/attr/impl.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/coverage/attr/impl.rs b/tests/coverage/attr/impl.rs new file mode 100644 index 00000000000..d4d784a3502 --- /dev/null +++ b/tests/coverage/attr/impl.rs @@ -0,0 +1,41 @@ +#![feature(coverage_attribute)] +//@ edition: 2021 + +// Checks that `#[coverage(..)]` can be applied to impl and impl-trait blocks, +// and is inherited by any enclosed functions. + +struct MyStruct; + +#[coverage(off)] +impl MyStruct { + fn off_inherit() {} + + #[coverage(on)] + fn off_on() {} + + #[coverage(off)] + fn off_off() {} +} + +#[coverage(on)] +impl MyStruct { + fn on_inherit() {} + + #[coverage(on)] + fn on_on() {} + + #[coverage(off)] + fn on_off() {} +} + +trait MyTrait { + fn method(); +} + +#[coverage(off)] +impl MyTrait for MyStruct { + fn method() {} +} + +#[coverage(off)] +fn main() {} |
