diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2024-07-01 17:04:38 +1000 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2024-07-08 20:24:15 +1000 |
| commit | 9b2c58d1faf2dba1aef0e8556cec8e0ca6b7b996 (patch) | |
| tree | 112b8f5799bb2429df89414cf855f58cc9406028 /tests/coverage/holes.rs | |
| parent | 7fdefb804ec300fb605039522a7c0dfc9e7dc366 (diff) | |
| download | rust-9b2c58d1faf2dba1aef0e8556cec8e0ca6b7b996.tar.gz rust-9b2c58d1faf2dba1aef0e8556cec8e0ca6b7b996.zip | |
coverage: Test for handling of nested item spans
Diffstat (limited to 'tests/coverage/holes.rs')
| -rw-r--r-- | tests/coverage/holes.rs | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/coverage/holes.rs b/tests/coverage/holes.rs new file mode 100644 index 00000000000..b3a71e759c8 --- /dev/null +++ b/tests/coverage/holes.rs @@ -0,0 +1,67 @@ +//@ edition: 2021 + +// Nested items/closures should be treated as "holes", so that their spans are +// not displayed as executable code in the enclosing function. + +use core::hint::black_box; + +fn main() { + black_box(()); + + // Splitting this across multiple lines makes it easier to see where the + // coverage mapping regions begin and end. + #[rustfmt::skip] + let _closure = + | + _arg: (), + | + { + black_box(()); + } + ; + + black_box(()); + + fn _unused_fn() {} + + black_box(()); + + struct MyStruct { + _x: u32, + _y: u32, + } + + black_box(()); + + impl MyStruct { + fn _method(&self) {} + } + + black_box(()); + + macro_rules! _my_macro { + () => {}; + } + + black_box(()); + + #[rustfmt::skip] + let _const = + const + { + 7 + 4 + } + ; + + black_box(()); + + #[rustfmt::skip] + let _async = + async + { + 7 + 4 + } + ; + + black_box(()); +} |
