Skip to content

Commit dc49513

Browse files
committed
Stabilize #[coverage] attribute
1 parent a48861a commit dc49513

File tree

84 files changed

+17
-153
lines changed

Some content is hidden

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

84 files changed

+17
-153
lines changed

Diff for: compiler/rustc_feature/src/accepted.rs

+3
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ declare_features! (
147147
(accepted, const_raw_ptr_deref, "1.58.0", Some(51911)),
148148
/// Allows implementing `Copy` for closures where possible (RFC 2132).
149149
(accepted, copy_closures, "1.26.0", Some(44490)),
150+
/// Allows function attribute `#[coverage(on/off)]`, to control coverage
151+
/// instrumentation of that function.
152+
(accepted, coverage_attribute, "CURRENT_RUSTC_VERSION", Some(84605)),
150153
/// Allows `crate` in paths.
151154
(accepted, crate_in_paths, "1.30.0", Some(45477)),
152155
/// Allows users to provide classes for fenced code block using `class:classname`.

Diff for: 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!(

Diff for: compiler/rustc_feature/src/unstable.rs

-3
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,6 @@ declare_features! (
421421
(unstable, coroutine_clone, "1.65.0", Some(95360)),
422422
/// Allows defining coroutines.
423423
(unstable, coroutines, "1.21.0", Some(43122)),
424-
/// Allows function attribute `#[coverage(on/off)]`, to control coverage
425-
/// instrumentation of that function.
426-
(unstable, coverage_attribute, "1.74.0", Some(84605)),
427424
/// Allows non-builtin attributes in inner attribute position.
428425
(unstable, custom_inner_attributes, "1.30.0", Some(54726)),
429426
/// Allows custom test frameworks with `#![test_runner]` and `#[test_case]`.

Diff for: 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
}

Diff for: 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
#![cfg_attr(bootstrap, feature(offset_of_nested))]
111112
#![feature(array_ptr_get)]
112113
#![feature(asm_experimental_arch)]
@@ -163,7 +164,6 @@
163164
#![feature(const_ub_checks)]
164165
#![feature(const_unicode_case_lookup)]
165166
#![feature(const_unsafecell_get_mut)]
166-
#![feature(coverage_attribute)]
167167
#![feature(do_not_recommend)]
168168
#![feature(duration_consts_float)]
169169
#![feature(internal_impls_macro)]

Diff for: 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 */

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

-30
This file was deleted.

Diff for: 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

Diff for: 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)]

Diff for: 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)]

Diff for: 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| |

Diff for: 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

Diff for: 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| |

Diff for: 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

Diff for: 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,

Diff for: 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,

Diff for: 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

Diff for: 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

Diff for: 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-

Diff for: 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

Diff for: 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)]`

Diff for: 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)]`

Diff for: 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| |

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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-

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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| |

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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-

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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]

Diff for: 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]

Diff for: tests/coverage/let_else_loop.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 <https://github.com/rust-lang/rust/issues/122738>.

Diff for: tests/coverage/let_else_loop.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 <https://github.com/rust-lang/rust/issues/122738>.

Diff for: tests/coverage/macro_in_closure.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| |// If a closure body consists entirely of a single bang-macro invocation, the

Diff for: tests/coverage/macro_in_closure.rs

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

43
// If a closure body consists entirely of a single bang-macro invocation, the

0 commit comments

Comments
 (0)