Skip to content

Commit 2a11c1d

Browse files
committed
Stabilize #[coverage] attribute
1 parent 7042c26 commit 2a11c1d

File tree

92 files changed

+84
-223
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+84
-223
lines changed

compiler/rustc_feature/src/accepted.rs

+3
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ declare_features! (
153153
(accepted, const_refs_to_cell, "CURRENT_RUSTC_VERSION", Some(80384)),
154154
/// Allows implementing `Copy` for closures where possible (RFC 2132).
155155
(accepted, copy_closures, "1.26.0", Some(44490)),
156+
/// Allows function attribute `#[coverage(on/off)]`, to control coverage
157+
/// instrumentation of that function.
158+
(accepted, coverage_attribute, "CURRENT_RUSTC_VERSION", Some(84605)),
156159
/// Allows `crate` in paths.
157160
(accepted, crate_in_paths, "1.30.0", Some(45477)),
158161
/// Allows users to provide classes for fenced code block using `class:classname`.

compiler/rustc_feature/src/builtin_attrs.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,9 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
482482
template!(List: "address, kcfi, memory, thread"), DuplicatesOk,
483483
EncodeCrossCrate::No, experimental!(no_sanitize)
484484
),
485-
gated!(
485+
ungated!(
486486
coverage, Normal, template!(OneOf: &[sym::off, sym::on]),
487487
ErrorPreceding, EncodeCrossCrate::No,
488-
coverage_attribute, experimental!(coverage)
489488
),
490489

491490
ungated!(

compiler/rustc_feature/src/unstable.rs

-3
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,6 @@ declare_features! (
417417
(unstable, coroutine_clone, "1.65.0", Some(95360)),
418418
/// Allows defining coroutines.
419419
(unstable, coroutines, "1.21.0", Some(43122)),
420-
/// Allows function attribute `#[coverage(on/off)]`, to control coverage
421-
/// instrumentation of that function.
422-
(unstable, coverage_attribute, "1.74.0", Some(84605)),
423420
/// Allows non-builtin attributes in inner attribute position.
424421
(unstable, custom_inner_attributes, "1.30.0", Some(54726)),
425422
/// Allows custom test frameworks with `#![test_runner]` and `#[test_case]`.

library/core/src/cmp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ pub trait Eq: PartialEq<Self> {
343343
#[rustc_builtin_macro]
344344
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
345345
#[allow_internal_unstable(core_intrinsics, derive_eq, structural_match)]
346-
#[allow_internal_unstable(coverage_attribute)]
346+
#[cfg_attr(bootstrap, allow_internal_unstable(coverage_attribute))]
347347
pub macro Eq($item:item) {
348348
/* compiler built-in */
349349
}

library/core/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
//
108108
// Library features:
109109
// tidy-alphabetical-start
110+
#![cfg_attr(bootstrap, feature(coverage_attribute))]
110111
#![feature(array_ptr_get)]
111112
#![feature(asm_experimental_arch)]
112113
#![feature(const_align_of_val)]
@@ -161,7 +162,6 @@
161162
#![feature(const_ub_checks)]
162163
#![feature(const_unicode_case_lookup)]
163164
#![feature(const_unsafecell_get_mut)]
164-
#![feature(coverage_attribute)]
165165
#![feature(do_not_recommend)]
166166
#![feature(duration_consts_float)]
167167
#![feature(f128_const)]

library/core/src/macros/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1654,7 +1654,8 @@ pub(crate) mod builtin {
16541654
///
16551655
/// [the reference]: ../../../reference/attributes/testing.html#the-test-attribute
16561656
#[stable(feature = "rust1", since = "1.0.0")]
1657-
#[allow_internal_unstable(test, rustc_attrs, coverage_attribute)]
1657+
#[allow_internal_unstable(test, rustc_attrs)]
1658+
#[cfg_attr(bootstrap, allow_internal_unstable(coverage_attribute))]
16581659
#[rustc_builtin_macro]
16591660
pub macro test($item:item) {
16601661
/* compiler built-in */
@@ -1667,7 +1668,8 @@ pub(crate) mod builtin {
16671668
soft,
16681669
reason = "`bench` is a part of custom test frameworks which are unstable"
16691670
)]
1670-
#[allow_internal_unstable(test, rustc_attrs, coverage_attribute)]
1671+
#[allow_internal_unstable(test, rustc_attrs)]
1672+
#[cfg_attr(bootstrap, allow_internal_unstable(coverage_attribute))]
16711673
#[rustc_builtin_macro]
16721674
pub macro bench($item:item) {
16731675
/* compiler built-in */

src/doc/unstable-book/src/language-features/coverage-attribute.md

-30
This file was deleted.

src/tools/rust-analyzer/crates/hir-expand/src/inert_attr_macro.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
237237
template!(List: "address, kcfi, memory, thread"), DuplicatesOk,
238238
experimental!(no_sanitize)
239239
),
240-
gated!(coverage, Normal, template!(Word, List: "on|off"), WarnFollowing, coverage_attribute, experimental!(coverage)),
240+
ungated!(coverage, Normal, template!(Word, List: "on|off"), WarnFollowing),
241241

242242
ungated!(
243243
doc, Normal, template!(List: "hidden|inline|...", NameValueStr: "string"), DuplicatesOk

tests/coverage/async.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |#![feature(custom_inner_attributes)] // for #![rustfmt::skip]
32
LL| |#![feature(noop_waker)]
43
LL| |#![allow(unused_assignments, dead_code)]

tests/coverage/async.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
#![feature(custom_inner_attributes)] // for #![rustfmt::skip]
32
#![feature(noop_waker)]
43
#![allow(unused_assignments, dead_code)]

tests/coverage/async2.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |#![feature(noop_waker)]
32
LL| |//@ edition: 2018
43
LL| |

tests/coverage/async2.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
#![feature(noop_waker)]
32
//@ edition: 2018
43

tests/coverage/async_block.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |#![feature(noop_waker)]
32
LL| |//@ edition: 2021
43
LL| |

tests/coverage/async_block.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
#![feature(noop_waker)]
32
//@ edition: 2021
43

tests/coverage/attr/impl.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |//@ edition: 2021
32
LL| |
43
LL| |// Checks that `#[coverage(..)]` can be applied to impl and impl-trait blocks,

tests/coverage/attr/impl.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
//@ edition: 2021
32

43
// Checks that `#[coverage(..)]` can be applied to impl and impl-trait blocks,

tests/coverage/attr/module.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |//@ edition: 2021
32
LL| |
43
LL| |// Checks that `#[coverage(..)]` can be applied to modules, and is inherited

tests/coverage/attr/module.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
//@ edition: 2021
32

43
// Checks that `#[coverage(..)]` can be applied to modules, and is inherited

tests/coverage/attr/nested.coverage

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
LL| |#![feature(coverage_attribute, stmt_expr_attributes)]
1+
LL| |#![feature(stmt_expr_attributes)]
22
LL| |//@ edition: 2021
33
LL| |
44
LL| |// Demonstrates the interaction between #[coverage(off)] and various kinds of
@@ -103,4 +103,3 @@
103103
LL| | closure_expr();
104104
LL| | closure_tail();
105105
LL| |}
106-

tests/coverage/attr/nested.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(coverage_attribute, stmt_expr_attributes)]
1+
#![feature(stmt_expr_attributes)]
22
//@ edition: 2021
33

44
// Demonstrates the interaction between #[coverage(off)] and various kinds of

tests/coverage/attr/off-on-sandwich.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |//@ edition: 2021
32
LL| |
43
LL| |// Demonstrates the interaction of `#[coverage(off)]` and `#[coverage(on)]`

tests/coverage/attr/off-on-sandwich.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
//@ edition: 2021
32

43
// Demonstrates the interaction of `#[coverage(off)]` and `#[coverage(on)]`

tests/coverage/auxiliary/executor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(coverage_attribute, noop_waker)]
1+
#![feature(noop_waker)]
22
//@ edition: 2021
33

44
use core::future::Future;

tests/coverage/await_ready.coverage

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |#![feature(noop_waker)]
32
LL| |#![coverage(off)]
43
LL| |//@ edition: 2021
@@ -22,4 +21,3 @@
2221
LL| | let mut future = Box::pin(await_ready());
2322
LL| | executor::block_on(future.as_mut());
2423
LL| |}
25-

tests/coverage/await_ready.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
#![feature(noop_waker)]
32
#![coverage(off)]
43
//@ edition: 2021

tests/coverage/bad_counter_ids.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |//@ edition: 2021
32
LL| |//@ compile-flags: -Copt-level=0 -Zmir-opt-level=3
43
LL| |

tests/coverage/bad_counter_ids.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
//@ edition: 2021
32
//@ compile-flags: -Copt-level=0 -Zmir-opt-level=3
43

tests/coverage/branch/generics.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |//@ edition: 2021
32
LL| |//@ compile-flags: -Zcoverage-options=branch
43
LL| |//@ llvm-cov-flags: --show-branches=count

tests/coverage/branch/generics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
//@ edition: 2021
32
//@ compile-flags: -Zcoverage-options=branch
43
//@ llvm-cov-flags: --show-branches=count

tests/coverage/branch/guard.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |//@ edition: 2021
32
LL| |//@ compile-flags: -Zcoverage-options=branch
43
LL| |//@ llvm-cov-flags: --show-branches=count

tests/coverage/branch/guard.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
//@ edition: 2021
32
//@ compile-flags: -Zcoverage-options=branch
43
//@ llvm-cov-flags: --show-branches=count

tests/coverage/branch/if-let.coverage

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
LL| |#![feature(coverage_attribute, let_chains)]
1+
LL| |#![feature(let_chains)]
22
LL| |//@ edition: 2021
33
LL| |//@ compile-flags: -Zcoverage-options=branch
44
LL| |//@ llvm-cov-flags: --show-branches=count
@@ -68,4 +68,3 @@
6868
LL| |}
6969
LL| |
7070
LL| |// FIXME(#124118) Actually instrument if-let and let-chains for branch coverage.
71-

tests/coverage/branch/if-let.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(coverage_attribute, let_chains)]
1+
#![feature(let_chains)]
22
//@ edition: 2021
33
//@ compile-flags: -Zcoverage-options=branch
44
//@ llvm-cov-flags: --show-branches=count

tests/coverage/branch/if.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |//@ edition: 2021
32
LL| |//@ compile-flags: -Zcoverage-options=branch
43
LL| |//@ llvm-cov-flags: --show-branches=count

tests/coverage/branch/if.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
//@ edition: 2021
32
//@ compile-flags: -Zcoverage-options=branch
43
//@ llvm-cov-flags: --show-branches=count

tests/coverage/branch/lazy-boolean.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |//@ edition: 2021
32
LL| |//@ compile-flags: -Zcoverage-options=branch
43
LL| |//@ llvm-cov-flags: --show-branches=count

tests/coverage/branch/lazy-boolean.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
//@ edition: 2021
32
//@ compile-flags: -Zcoverage-options=branch
43
//@ llvm-cov-flags: --show-branches=count

tests/coverage/branch/let-else.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |//@ edition: 2021
32
LL| |//@ compile-flags: -Zcoverage-options=branch
43
LL| |//@ llvm-cov-flags: --show-branches=count

tests/coverage/branch/let-else.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
//@ edition: 2021
32
//@ compile-flags: -Zcoverage-options=branch
43
//@ llvm-cov-flags: --show-branches=count

tests/coverage/branch/match-arms.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |//@ edition: 2021
32
LL| |//@ compile-flags: -Zcoverage-options=branch
43
LL| |//@ llvm-cov-flags: --show-branches=count

tests/coverage/branch/match-arms.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
//@ edition: 2021
32
//@ compile-flags: -Zcoverage-options=branch
43
//@ llvm-cov-flags: --show-branches=count

tests/coverage/branch/match-trivial.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |//@ edition: 2021
32
LL| |//@ compile-flags: -Zcoverage-options=branch
43
LL| |//@ llvm-cov-flags: --show-branches=count

tests/coverage/branch/match-trivial.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
//@ edition: 2021
32
//@ compile-flags: -Zcoverage-options=branch
43
//@ llvm-cov-flags: --show-branches=count

tests/coverage/branch/no-mir-spans.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |//@ edition: 2021
32
LL| |//@ compile-flags: -Zcoverage-options=branch,no-mir-spans
43
LL| |//@ llvm-cov-flags: --show-branches=count

tests/coverage/branch/no-mir-spans.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
//@ edition: 2021
32
//@ compile-flags: -Zcoverage-options=branch,no-mir-spans
43
//@ llvm-cov-flags: --show-branches=count

tests/coverage/branch/while.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |//@ edition: 2021
32
LL| |//@ compile-flags: -Zcoverage-options=branch
43
LL| |//@ llvm-cov-flags: --show-branches=count

tests/coverage/branch/while.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
//@ edition: 2021
32
//@ compile-flags: -Zcoverage-options=branch
43
//@ llvm-cov-flags: --show-branches=count

tests/coverage/closure_macro_async.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |#![feature(noop_waker)]
32
LL| |//@ edition: 2018
43
LL| |

tests/coverage/closure_macro_async.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
#![feature(noop_waker)]
32
//@ edition: 2018
43

tests/coverage/closure_unit_return.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |//@ edition: 2021
32
LL| |
43
LL| |// Regression test for an inconsistency between functions that return the value

tests/coverage/closure_unit_return.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
//@ edition: 2021
32

43
// Regression test for an inconsistency between functions that return the value

tests/coverage/condition/conditions.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |//@ edition: 2021
32
LL| |//@ compile-flags: -Zcoverage-options=condition
43
LL| |//@ llvm-cov-flags: --show-branches=count

tests/coverage/condition/conditions.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
//@ edition: 2021
32
//@ compile-flags: -Zcoverage-options=condition
43
//@ llvm-cov-flags: --show-branches=count

tests/coverage/coverage_attr_closure.coverage

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
LL| |#![feature(coverage_attribute, stmt_expr_attributes)]
1+
LL| |#![feature(stmt_expr_attributes)]
22
LL| |#![allow(dead_code)]
33
LL| |//@ edition: 2021
44
LL| |
@@ -40,4 +40,3 @@
4040
LL| | contains_closures_on();
4141
LL| | contains_closures_off();
4242
LL| |}
43-

tests/coverage/coverage_attr_closure.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(coverage_attribute, stmt_expr_attributes)]
1+
#![feature(stmt_expr_attributes)]
22
#![allow(dead_code)]
33
//@ edition: 2021
44

tests/coverage/fn_sig_into_try.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |//@ edition: 2021
32
LL| |
43
LL| |// Regression test for inconsistent handling of function signature spans that

tests/coverage/fn_sig_into_try.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
//@ edition: 2021
32

43
// Regression test for inconsistent handling of function signature spans that

tests/coverage/if_not.coverage

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LL| |#![feature(coverage_attribute)]
21
LL| |//@ edition: 2021
32
LL| |
43
LL| |#[rustfmt::skip]

tests/coverage/if_not.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coverage_attribute)]
21
//@ edition: 2021
32

43
#[rustfmt::skip]

0 commit comments

Comments
 (0)