From 679267f2ac291202e9c8168edd1df8a9cf3aecb2 Mon Sep 17 00:00:00 2001 From: Andy Caldwell Date: Thu, 24 Aug 2023 20:15:41 +0100 Subject: Rename the feature, but not the attribute, to `coverage_attribute` --- compiler/rustc_builtin_macros/src/test_harness.rs | 2 +- compiler/rustc_feature/src/active.rs | 2 +- compiler/rustc_feature/src/builtin_attrs.rs | 2 +- compiler/rustc_span/src/symbol.rs | 1 + library/core/src/cmp.rs | 2 +- library/core/src/lib.rs | 2 +- .../src/language-features/coverage-attribute.md | 30 ++++++++++++++++++++++ .../src/language-features/coverage.md | 30 ---------------------- .../feature-gate-coverage-attribute.rs | 14 ++++++++++ .../feature-gate-coverage-attribute.stderr | 21 +++++++++++++++ tests/ui/feature-gates/feature-gate-coverage.rs | 14 ---------- .../ui/feature-gates/feature-gate-coverage.stderr | 21 --------------- tests/ui/lint/no-coverage.rs | 2 +- 13 files changed, 72 insertions(+), 71 deletions(-) create mode 100644 src/doc/unstable-book/src/language-features/coverage-attribute.md delete mode 100644 src/doc/unstable-book/src/language-features/coverage.md create mode 100644 tests/ui/feature-gates/feature-gate-coverage-attribute.rs create mode 100644 tests/ui/feature-gates/feature-gate-coverage-attribute.stderr delete mode 100644 tests/ui/feature-gates/feature-gate-coverage.rs delete mode 100644 tests/ui/feature-gates/feature-gate-coverage.stderr diff --git a/compiler/rustc_builtin_macros/src/test_harness.rs b/compiler/rustc_builtin_macros/src/test_harness.rs index ed0da7e115f..53ff089d7b4 100644 --- a/compiler/rustc_builtin_macros/src/test_harness.rs +++ b/compiler/rustc_builtin_macros/src/test_harness.rs @@ -254,7 +254,7 @@ fn generate_test_harness( let expn_id = ext_cx.resolver.expansion_for_ast_pass( DUMMY_SP, AstPass::TestHarness, - &[sym::test, sym::rustc_attrs, sym::coverage], + &[sym::test, sym::rustc_attrs, sym::coverage_attribute], None, ); let def_site = DUMMY_SP.with_def_site_ctxt(expn_id.to_expn_id()); diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 7da6f763e99..fcb112eadfe 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -400,7 +400,7 @@ declare_features! ( (active, const_try, "1.56.0", Some(74935), None), /// Allows function attribute `#[coverage(on/off)]`, to control coverage /// instrumentation of that function. - (active, coverage, "CURRENT_RUSTC_VERSION", Some(84605), None), + (active, coverage_attribute, "CURRENT_RUSTC_VERSION", Some(84605), None), /// Allows non-builtin attributes in inner attribute position. (active, custom_inner_attributes, "1.30.0", Some(54726), None), /// Allows custom test frameworks with `#![test_runner]` and `#[test_case]`. diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 49fd27de804..b4b794d4e09 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -395,7 +395,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ template!(List: "address, kcfi, memory, thread"), DuplicatesOk, experimental!(no_sanitize) ), - gated!(coverage, Normal, template!(Word, List: "on|off"), WarnFollowing, experimental!(coverage)), + gated!(coverage, Normal, template!(Word, List: "on|off"), WarnFollowing, coverage_attribute, experimental!(coverage)), ungated!( doc, Normal, template!(List: "hidden|inline|...", NameValueStr: "string"), DuplicatesOk diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index a8425b2dc04..23ea8fe8f5a 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -574,6 +574,7 @@ symbols! { cosf64, count, coverage, + coverage_attribute, cr, crate_id, crate_in_paths, diff --git a/library/core/src/cmp.rs b/library/core/src/cmp.rs index be9f75deead..6d5133646b5 100644 --- a/library/core/src/cmp.rs +++ b/library/core/src/cmp.rs @@ -301,7 +301,7 @@ pub trait Eq: PartialEq { #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[allow_internal_unstable(core_intrinsics, derive_eq, structural_match)] #[cfg_attr(bootstrap, allow_internal_unstable(no_coverage))] -#[cfg_attr(not(bootstrap), allow_internal_unstable(coverage))] +#[cfg_attr(not(bootstrap), allow_internal_unstable(coverage_attribute))] pub macro Eq($item:item) { /* compiler built-in */ } diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index e049dcc6eba..7c08d1703cc 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -111,7 +111,7 @@ // Library features: // tidy-alphabetical-start #![cfg_attr(bootstrap, feature(no_coverage))] // rust-lang/rust#84605 -#![cfg_attr(not(bootstrap), feature(coverage))] // rust-lang/rust#84605 +#![cfg_attr(not(bootstrap), feature(coverage_attribute))] // rust-lang/rust#84605 #![feature(char_indices_offset)] #![feature(const_align_of_val)] #![feature(const_align_of_val_raw)] diff --git a/src/doc/unstable-book/src/language-features/coverage-attribute.md b/src/doc/unstable-book/src/language-features/coverage-attribute.md new file mode 100644 index 00000000000..0a9bd07de07 --- /dev/null +++ b/src/doc/unstable-book/src/language-features/coverage-attribute.md @@ -0,0 +1,30 @@ +# `coverage_attribute` + +The tracking issue for this feature is: [#84605] + +[#84605]: https://github.com/rust-lang/rust/issues/84605 + +--- + +The `coverage` attribute can be used to selectively disable coverage +instrumentation in an annotated function. This might be useful to: + +- Avoid instrumentation overhead in a performance critical function +- Avoid generating coverage for a function that is not meant to be executed, + but still target 100% coverage for the rest of the program. + +## Example + +```rust +#![feature(coverage_attribute)] + +// `foo()` will get coverage instrumentation (by default) +fn foo() { + // ... +} + +#[coverage(off)] +fn bar() { + // ... +} +``` diff --git a/src/doc/unstable-book/src/language-features/coverage.md b/src/doc/unstable-book/src/language-features/coverage.md deleted file mode 100644 index d200bf6b2bc..00000000000 --- a/src/doc/unstable-book/src/language-features/coverage.md +++ /dev/null @@ -1,30 +0,0 @@ -# `coverage` - -The tracking issue for this feature is: [#84605] - -[#84605]: https://github.com/rust-lang/rust/issues/84605 - ---- - -The `coverage` attribute can be used to selectively disable coverage -instrumentation in an annotated function. This might be useful to: - -- Avoid instrumentation overhead in a performance critical function -- Avoid generating coverage for a function that is not meant to be executed, - but still target 100% coverage for the rest of the program. - -## Example - -```rust -#![feature(coverage)] - -// `foo()` will get coverage instrumentation (by default) -fn foo() { - // ... -} - -#[coverage(off)] -fn bar() { - // ... -} -``` diff --git a/tests/ui/feature-gates/feature-gate-coverage-attribute.rs b/tests/ui/feature-gates/feature-gate-coverage-attribute.rs new file mode 100644 index 00000000000..0a463755f13 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-coverage-attribute.rs @@ -0,0 +1,14 @@ +#![crate_type = "lib"] +#![feature(no_coverage)] //~ ERROR feature has been removed [E0557] + +#[derive(PartialEq, Eq)] // ensure deriving `Eq` does not enable `feature(coverage)` +struct Foo { + a: u8, + b: u32, +} + +#[coverage(off)] //~ ERROR the `#[coverage]` attribute is an experimental feature +fn requires_feature_coverage() -> bool { + let bar = Foo { a: 0, b: 0 }; + bar == Foo { a: 0, b: 0 } +} diff --git a/tests/ui/feature-gates/feature-gate-coverage-attribute.stderr b/tests/ui/feature-gates/feature-gate-coverage-attribute.stderr new file mode 100644 index 00000000000..3912b9834fe --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-coverage-attribute.stderr @@ -0,0 +1,21 @@ +error[E0557]: feature has been removed + --> $DIR/feature-gate-coverage-attribute.rs:2:12 + | +LL | #![feature(no_coverage)] + | ^^^^^^^^^^^ feature has been removed + | + = note: renamed to `coverage` + +error[E0658]: the `#[coverage]` attribute is an experimental feature + --> $DIR/feature-gate-coverage-attribute.rs:10:1 + | +LL | #[coverage(off)] + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #84605 for more information + = help: add `#![feature(coverage_attribute)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0557, E0658. +For more information about an error, try `rustc --explain E0557`. diff --git a/tests/ui/feature-gates/feature-gate-coverage.rs b/tests/ui/feature-gates/feature-gate-coverage.rs deleted file mode 100644 index 0a463755f13..00000000000 --- a/tests/ui/feature-gates/feature-gate-coverage.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![crate_type = "lib"] -#![feature(no_coverage)] //~ ERROR feature has been removed [E0557] - -#[derive(PartialEq, Eq)] // ensure deriving `Eq` does not enable `feature(coverage)` -struct Foo { - a: u8, - b: u32, -} - -#[coverage(off)] //~ ERROR the `#[coverage]` attribute is an experimental feature -fn requires_feature_coverage() -> bool { - let bar = Foo { a: 0, b: 0 }; - bar == Foo { a: 0, b: 0 } -} diff --git a/tests/ui/feature-gates/feature-gate-coverage.stderr b/tests/ui/feature-gates/feature-gate-coverage.stderr deleted file mode 100644 index 25d56912ecd..00000000000 --- a/tests/ui/feature-gates/feature-gate-coverage.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0557]: feature has been removed - --> $DIR/feature-gate-coverage.rs:2:12 - | -LL | #![feature(no_coverage)] - | ^^^^^^^^^^^ feature has been removed - | - = note: renamed to `coverage` - -error[E0658]: the `#[coverage]` attribute is an experimental feature - --> $DIR/feature-gate-coverage.rs:10:1 - | -LL | #[coverage(off)] - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #84605 for more information - = help: add `#![feature(coverage)]` to the crate attributes to enable - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0557, E0658. -For more information about an error, try `rustc --explain E0557`. diff --git a/tests/ui/lint/no-coverage.rs b/tests/ui/lint/no-coverage.rs index 92a5ecf51ad..907d25d333e 100644 --- a/tests/ui/lint/no-coverage.rs +++ b/tests/ui/lint/no-coverage.rs @@ -1,5 +1,5 @@ #![feature(extern_types)] -#![feature(coverage)] +#![feature(coverage_attribute)] #![feature(impl_trait_in_assoc_type)] #![warn(unused_attributes)] #![coverage(off)] -- cgit 1.4.1-3-g733a5