Rollup merge of #84871 - richkadel:no-coverage-unstable-only, r=nagisa
Disallows `#![feature(no_coverage)]` on stable and beta (using standard crate-level gating) Fixes: #84836 Removes the function-level feature gating solution originally implemented, and solves the same problem using `allow_internal_unstable`, so normal crate-level feature gating mechanism can still be used (which disallows the feature on stable and beta). I tested this, building the compiler with and without `CFG_DISABLE_UNSTABLE_FEATURES=1` With unstable features disabled, I get the expected result as shown here: ```shell $ ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc src/test/run-make-fulldeps/coverage/no_cov_crate.rs error[E0554]: `#![feature]` may not be used on the dev release channel --> src/test/run-make-fulldeps/coverage/no_cov_crate.rs:2:1 | 2 | #![feature(no_coverage)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0554`. ``` r? ````@Mark-Simulacrum```` cc: ````@tmandry```` ````@wesleywiser````
This commit is contained in:
commit
aaf23892ab
9 changed files with 18 additions and 91 deletions
|
@ -2661,8 +2661,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
|
|||
let mut inline_span = None;
|
||||
let mut link_ordinal_span = None;
|
||||
let mut no_sanitize_span = None;
|
||||
let mut no_coverage_feature_enabled = false;
|
||||
let mut no_coverage_attr = None;
|
||||
for attr in attrs.iter() {
|
||||
if tcx.sess.check_name(attr, sym::cold) {
|
||||
codegen_fn_attrs.flags |= CodegenFnAttrFlags::COLD;
|
||||
|
@ -2726,15 +2724,8 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
|
|||
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NAKED;
|
||||
} else if tcx.sess.check_name(attr, sym::no_mangle) {
|
||||
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_MANGLE;
|
||||
} else if attr.has_name(sym::feature) {
|
||||
if let Some(list) = attr.meta_item_list() {
|
||||
if list.iter().any(|nested_meta_item| nested_meta_item.has_name(sym::no_coverage)) {
|
||||
tcx.sess.mark_attr_used(attr);
|
||||
no_coverage_feature_enabled = true;
|
||||
}
|
||||
}
|
||||
} else if tcx.sess.check_name(attr, sym::no_coverage) {
|
||||
no_coverage_attr = Some(attr);
|
||||
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_COVERAGE;
|
||||
} else if tcx.sess.check_name(attr, sym::rustc_std_internal_symbol) {
|
||||
codegen_fn_attrs.flags |= CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL;
|
||||
} else if tcx.sess.check_name(attr, sym::used) {
|
||||
|
@ -2945,23 +2936,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(no_coverage_attr) = no_coverage_attr {
|
||||
if tcx.sess.features_untracked().no_coverage || no_coverage_feature_enabled {
|
||||
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_COVERAGE
|
||||
} else {
|
||||
let mut err = feature_err(
|
||||
&tcx.sess.parse_sess,
|
||||
sym::no_coverage,
|
||||
no_coverage_attr.span,
|
||||
"the `#[no_coverage]` attribute is an experimental feature",
|
||||
);
|
||||
if tcx.sess.parse_sess.unstable_features.is_nightly_build() {
|
||||
err.help("or, alternatively, add `#[feature(no_coverage)]` to the function");
|
||||
}
|
||||
err.emit();
|
||||
}
|
||||
}
|
||||
|
||||
codegen_fn_attrs.inline = attrs.iter().fold(InlineAttr::None, |ia, attr| {
|
||||
if !attr.has_name(sym::inline) {
|
||||
return ia;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue