Skip to content

Commit f687e3c

Browse files
authored
Rollup merge of rust-lang#120183 - Zalathar:test-closure, r=compiler-errors
Add `#[coverage(off)]` to closures introduced by `#[test]` and `#[bench]` These closures are an internal implementation detail of the `#[test]` and `#[bench]` attribute macros, so from a user perspective there is no reason to instrument them for coverage. Skipping them makes coverage reports slightly cleaner, and will also allow other changes to span processing during coverage instrumentation, without having to worry about how they affect the `#[test]` macro. The `#[coverage(off)]` attribute has no effect when `-Cinstrument-coverage` is not used. Fixes rust-lang#120046. --- Note that this PR has no effect on the user-written function that has the `#[test]` attribute attached to it. That function will still be instrumented as normal.
2 parents 2b544b5 + e0b37fe commit f687e3c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/src/macros/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,7 @@ pub(crate) mod builtin {
15961596
///
15971597
/// [the reference]: ../../../reference/attributes/testing.html#the-test-attribute
15981598
#[stable(feature = "rust1", since = "1.0.0")]
1599-
#[allow_internal_unstable(test, rustc_attrs)]
1599+
#[allow_internal_unstable(test, rustc_attrs, coverage_attribute)]
16001600
#[rustc_builtin_macro]
16011601
pub macro test($item:item) {
16021602
/* compiler built-in */
@@ -1609,7 +1609,7 @@ pub(crate) mod builtin {
16091609
soft,
16101610
reason = "`bench` is a part of custom test frameworks which are unstable"
16111611
)]
1612-
#[allow_internal_unstable(test, rustc_attrs)]
1612+
#[allow_internal_unstable(test, rustc_attrs, coverage_attribute)]
16131613
#[rustc_builtin_macro]
16141614
pub macro bench($item:item) {
16151615
/* compiler built-in */

0 commit comments

Comments
 (0)