Skip to content

Commit 94bc08d

Browse files
authored
Rollup merge of rust-lang#101772 - est31:replace_placeholder_diagnostics, r=jackh726
Also replace the placeholder for the stable_features lint Follow up of rust-lang#101215 and rust-lang#100591 . Fixes rust-lang#101766
2 parents dce4715 + 3a38d56 commit 94bc08d

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

compiler/rustc_attr/src/builtin.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};
2121
/// For more, see [this pull request](https://github.com/rust-lang/rust/pull/100591).
2222
pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
2323

24+
pub fn rust_version_symbol() -> Symbol {
25+
let version = option_env!("CFG_VERSION").unwrap_or("<current>");
26+
let version = version.split(' ').next().unwrap();
27+
Symbol::intern(&version)
28+
}
29+
2430
pub fn is_builtin_attr(attr: &Attribute) -> bool {
2531
attr.is_doc_comment() || attr.ident().filter(|ident| is_builtin_attr_name(ident.name)).is_some()
2632
}
@@ -495,9 +501,7 @@ where
495501
}
496502

497503
if let Some(s) = since && s.as_str() == VERSION_PLACEHOLDER {
498-
let version = option_env!("CFG_VERSION").unwrap_or("<current>");
499-
let version = version.split(' ').next().unwrap();
500-
since = Some(Symbol::intern(&version));
504+
since = Some(rust_version_symbol());
501505
}
502506

503507
match (feature, since) {

compiler/rustc_passes/src/lib_features.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! collect them instead.
66
77
use rustc_ast::{Attribute, MetaItemKind};
8-
use rustc_attr::VERSION_PLACEHOLDER;
8+
use rustc_attr::{rust_version_symbol, VERSION_PLACEHOLDER};
99
use rustc_errors::struct_span_err;
1010
use rustc_hir::intravisit::Visitor;
1111
use rustc_middle::hir::nested_filter;
@@ -57,9 +57,7 @@ impl<'tcx> LibFeatureCollector<'tcx> {
5757
}
5858

5959
if let Some(s) = since && s.as_str() == VERSION_PLACEHOLDER {
60-
let version = option_env!("CFG_VERSION").unwrap_or("<current>");
61-
let version = version.split(' ').next().unwrap();
62-
since = Some(Symbol::intern(&version));
60+
since = Some(rust_version_symbol());
6361
}
6462

6563
if let Some(feature) = feature {

compiler/rustc_passes/src/stability.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//! propagating default levels lexically from parent to children ast nodes.
33
44
use rustc_attr::{
5-
self as attr, ConstStability, Stability, StabilityLevel, Unstable, UnstableReason,
5+
self as attr, rust_version_symbol, ConstStability, Stability, StabilityLevel, Unstable,
6+
UnstableReason, VERSION_PLACEHOLDER,
67
};
78
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
89
use rustc_errors::{struct_span_err, Applicability};
@@ -1106,7 +1107,15 @@ fn unnecessary_partially_stable_feature_lint(
11061107
});
11071108
}
11081109

1109-
fn unnecessary_stable_feature_lint(tcx: TyCtxt<'_>, span: Span, feature: Symbol, since: Symbol) {
1110+
fn unnecessary_stable_feature_lint(
1111+
tcx: TyCtxt<'_>,
1112+
span: Span,
1113+
feature: Symbol,
1114+
mut since: Symbol,
1115+
) {
1116+
if since.as_str() == VERSION_PLACEHOLDER {
1117+
since = rust_version_symbol();
1118+
}
11101119
tcx.struct_span_lint_hir(lint::builtin::STABLE_FEATURES, hir::CRATE_HIR_ID, span, |lint| {
11111120
lint.build(&format!(
11121121
"the feature `{feature}` has been stable since {since} and no longer requires an \

0 commit comments

Comments
 (0)