diff options
| author | The rustc-josh-sync Cronjob Bot <github-actions@github.com> | 2025-07-31 04:20:38 +0000 |
|---|---|---|
| committer | The rustc-josh-sync Cronjob Bot <github-actions@github.com> | 2025-07-31 04:20:38 +0000 |
| commit | 49aa0ecc7b251003e61c38a56471195a2d3dabee (patch) | |
| tree | 8e45b6d6c87793c20c7254621a3bbe501d4ac718 /tests/coverage/try-in-macro.attr.coverage | |
| parent | 8926d9cc0325f87dfc1959043097204bca49a1d9 (diff) | |
| parent | 32e7a4b92b109c24e9822c862a7c74436b50e564 (diff) | |
| download | rust-49aa0ecc7b251003e61c38a56471195a2d3dabee.tar.gz rust-49aa0ecc7b251003e61c38a56471195a2d3dabee.zip | |
Merge ref '32e7a4b92b10' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: 32e7a4b92b109c24e9822c862a7c74436b50e564 Filtered ref: 56d8aa13f54944edb711f3bdd7013b082dbaa65b This merge was created using https://github.com/rust-lang/josh-sync.
Diffstat (limited to 'tests/coverage/try-in-macro.attr.coverage')
| -rw-r--r-- | tests/coverage/try-in-macro.attr.coverage | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/coverage/try-in-macro.attr.coverage b/tests/coverage/try-in-macro.attr.coverage new file mode 100644 index 00000000000..457a161f3c7 --- /dev/null +++ b/tests/coverage/try-in-macro.attr.coverage @@ -0,0 +1,44 @@ + LL| |//! Regression test for <https://github.com/rust-lang/rust/issues/141577>. + LL| |//! + LL| |//! The changes in <https://github.com/rust-lang/rust/pull/144298> exposed a + LL| |//! latent bug that would sometimes cause the compiler to emit a covfun record + LL| |//! for a function, but not emit a corresponding PGO symbol name entry, because + LL| |//! the function did not have any physical coverage counters. The `llvm-cov` + LL| |//! tool would then fail to resolve the covfun record's function name hash, + LL| |//! and exit with the cryptic error: + LL| |//! + LL| |//! ```text + LL| |//! malformed instrumentation profile data: function name is empty + LL| |//! ``` + LL| |//! + LL| |//! The bug was then triggered in the wild by the macro-expansion of + LL| |//! `#[derive(arbitrary::Arbitrary)]`. + LL| |//! + LL| |//! This test uses a minimized form of the `Arbitrary` derive macro that was + LL| |//! found to still trigger the original bug. The bug could also be triggered + LL| |//! by a bang proc-macro or an attribute proc-macro. + LL| | + LL| |//@ edition: 2024 + LL| |//@ revisions: attr bang derive + LL| |//@ proc-macro: try_in_macro_helper.rs + LL| | + LL| |trait Arbitrary { + LL| | fn try_size_hint() -> Option<usize>; + LL| |} + LL| | + LL| |// Expand via an attribute proc-macro. + LL| |#[cfg_attr(attr, try_in_macro_helper::attr)] + LL| |const _: () = (); + LL| | + LL| |// Expand via a regular bang-style proc-macro. + LL| |#[cfg(bang)] + LL| |try_in_macro_helper::bang!(); + LL| | + LL| |// Expand via a derive proc-macro. + LL| |#[cfg_attr(derive, derive(try_in_macro_helper::Arbitrary))] + LL| |enum MyEnum {} + LL| | + LL| 1|fn main() { + LL| 1| MyEnum::try_size_hint(); + LL| 1|} + |
