Skip to content

Commit da8ad85

Browse files
authored
Unrolled build for rust-lang#134672
Rollup merge of rust-lang#134672 - Zalathar:revert-coverage-attr, r=wesleywiser Revert stabilization of the `#[coverage(..)]` attribute Due to a process mixup, the PR to stabilize the `#[coverage(..)]` attribute (rust-lang#130766) was merged while there are still outstanding concerns. The default action in that situation is to revert, and the feature is not sufficiently urgent or uncontroversial to justify special treatment, so this PR reverts that stabilization. --- - A key point that came up in offline discussions is that unlike most user-facing features, this one never had a proper RFC, so parts of the normal stabilization process that implicitly rely on an RFC break down in this case. - As the implementor and de-facto owner of the feature in its current form, I would like to think that I made good choices in designing and implementing it, but I don't feel comfortable proceeding to stabilization without further scrutiny. - There hasn't been a clear opportunity for T-compiler to weigh in or express concerns prior to stabilization. - The stabilization PR cites a T-lang FCP that occurred in the tracking issue, but due to the messy design and implementation history (and lack of a clear RFC), it's unclear what that FCP approval actually represents in this case. - At the very least, we should not proceed without a clear statement from T-lang or the relevant members about the team's stance on this feature, especially in light of the other concerns listed here. - The existing user-facing documentation doesn't clearly reflect which parts of the feature are stable commitments, and which parts are subject to change. And there doesn't appear to be a clear consensus anywhere about where that line is actually drawn, or whether the chosen boundary is acceptable to the relevant teams and individuals. - For example, the [stabilization report comment](rust-lang#84605 (comment)) mentions that some aspects are subject to change, but that text isn't consistent with my earlier comments, and there doesn't appear to have been any explicit discussion or approval process. - [The current reference text](https://github.com/rust-lang/reference/blob/4dfaa4f/src/attributes/coverage-instrumentation.md) doesn't mention this distinction at all, and instead simply describes the current implementation behaviour. - When the implementation was changed to its current form, the associated user-facing error messages were not updated, so they still refer to the attribute only being allowed on functions and closures. - On its own, this might have been reasonable to fix-forward in the absence of other concerns, but the fact that it never came up earlier highlights the breakdown in process that has occurred here. --- Apologies to everyone who was excited for this stabilization to land, but unfortunately it simply isn't ready yet.
2 parents 66bb586 + 87c2f9a commit da8ad85

File tree

128 files changed

+510
-369
lines changed

Some content is hidden

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

128 files changed

+510
-369
lines changed

compiler/rustc_feature/src/accepted.rs

-3
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,6 @@ declare_features! (
157157
(accepted, const_refs_to_static, "1.83.0", Some(119618)),
158158
/// Allows implementing `Copy` for closures where possible (RFC 2132).
159159
(accepted, copy_closures, "1.26.0", Some(44490)),
160-
/// Allows function attribute `#[coverage(on/off)]`, to control coverage
161-
/// instrumentation of that function.
162-
(accepted, coverage_attribute, "CURRENT_RUSTC_VERSION", Some(84605)),
163160
/// Allows `crate` in paths.
164161
(accepted, crate_in_paths, "1.30.0", Some(45477)),
165162
/// Allows users to provide classes for fenced code block using `class:classname`.

compiler/rustc_feature/src/builtin_attrs.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
480480
template!(List: "address, kcfi, memory, thread"), DuplicatesOk,
481481
EncodeCrossCrate::No, experimental!(no_sanitize)
482482
),
483-
ungated!(
483+
gated!(
484484
coverage, Normal, template!(OneOf: &[sym::off, sym::on]),
485485
ErrorPreceding, EncodeCrossCrate::No,
486+
coverage_attribute, experimental!(coverage)
486487
),
487488

488489
ungated!(

compiler/rustc_feature/src/unstable.rs

+3
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ declare_features! (
447447
(unstable, coroutine_clone, "1.65.0", Some(95360)),
448448
/// Allows defining coroutines.
449449
(unstable, coroutines, "1.21.0", Some(43122)),
450+
/// Allows function attribute `#[coverage(on/off)]`, to control coverage
451+
/// instrumentation of that function.
452+
(unstable, coverage_attribute, "1.74.0", Some(84605)),
450453
/// Allows non-builtin attributes in inner attribute position.
451454
(unstable, custom_inner_attributes, "1.30.0", Some(54726)),
452455
/// 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
@@ -348,7 +348,7 @@ pub trait Eq: PartialEq<Self> {
348348
#[rustc_builtin_macro]
349349
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
350350
#[allow_internal_unstable(core_intrinsics, derive_eq, structural_match)]
351-
#[cfg_attr(bootstrap, allow_internal_unstable(coverage_attribute))]
351+
#[allow_internal_unstable(coverage_attribute)]
352352
pub macro Eq($item:item) {
353353
/* compiler built-in */
354354
}

library/core/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@
107107
//
108108
// Library features:
109109
// tidy-alphabetical-start
110-
#![cfg_attr(bootstrap, feature(coverage_attribute))]
111110
#![cfg_attr(bootstrap, feature(do_not_recommend))]
112111
#![feature(array_ptr_get)]
113112
#![feature(asm_experimental_arch)]
114113
#![feature(const_eval_select)]
115114
#![feature(const_typed_swap)]
116115
#![feature(core_intrinsics)]
116+
#![feature(coverage_attribute)]
117117
#![feature(internal_impls_macro)]
118118
#![feature(ip)]
119119
#![feature(is_ascii_octdigit)]

library/core/src/macros/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1673,8 +1673,7 @@ pub(crate) mod builtin {
16731673
///
16741674
/// [the reference]: ../../../reference/attributes/testing.html#the-test-attribute
16751675
#[stable(feature = "rust1", since = "1.0.0")]
1676-
#[allow_internal_unstable(test, rustc_attrs)]
1677-
#[cfg_attr(bootstrap, allow_internal_unstable(coverage_attribute))]
1676+
#[allow_internal_unstable(test, rustc_attrs, coverage_attribute)]
16781677
#[rustc_builtin_macro]
16791678
pub macro test($item:item) {
16801679
/* compiler built-in */
@@ -1687,8 +1686,7 @@ pub(crate) mod builtin {
16871686
soft,
16881687
reason = "`bench` is a part of custom test frameworks which are unstable"
16891688
)]
1690-
#[allow_internal_unstable(test, rustc_attrs)]
1691-
#[cfg_attr(bootstrap, allow_internal_unstable(coverage_attribute))]
1689+
#[allow_internal_unstable(test, rustc_attrs, coverage_attribute)]
16921690
#[rustc_builtin_macro]
16931691
pub macro bench($item:item) {
16941692
/* compiler built-in */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# `coverage_attribute`
2+
3+
The tracking issue for this feature is: [#84605]
4+
5+
[#84605]: https://github.com/rust-lang/rust/issues/84605
6+
7+
---
8+
9+
The `coverage` attribute can be used to selectively disable coverage
10+
instrumentation in an annotated function. This might be useful to:
11+
12+
- Avoid instrumentation overhead in a performance critical function
13+
- Avoid generating coverage for a function that is not meant to be executed,
14+
but still target 100% coverage for the rest of the program.
15+
16+
## Example
17+
18+
```rust
19+
#![feature(coverage_attribute)]
20+
21+
// `foo()` will get coverage instrumentation (by default)
22+
fn foo() {
23+
// ...
24+
}
25+
26+
#[coverage(off)]
27+
fn bar() {
28+
// ...
29+
}
30+
```

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-
ungated!(coverage, Normal, template!(Word, List: "on|off"), WarnFollowing),
240+
gated!(coverage, Normal, template!(Word, List: "on|off"), WarnFollowing, coverage_attribute, experimental!(coverage)),
241241

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

0 commit comments

Comments
 (0)