Skip to content

Commit ac4fa3f

Browse files
committed
Pre-intern a symbol for env!("CFG_RELEASE")
1 parent 5563a9b commit ac4fa3f

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

compiler/rustc_attr/src/builtin.rs

-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
2626

2727
pub const CURRENT_RUSTC_VERSION: &str = env!("CFG_RELEASE");
2828

29-
pub fn rust_version_symbol() -> Symbol {
30-
Symbol::intern(CURRENT_RUSTC_VERSION)
31-
}
32-
3329
pub fn is_builtin_attr(attr: &Attribute) -> bool {
3430
attr.is_doc_comment() || attr.ident().is_some_and(|ident| is_builtin_attr_name(ident.name))
3531
}

compiler/rustc_passes/src/lib_features.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! collect them instead.
66
77
use rustc_ast::Attribute;
8-
use rustc_attr::{rust_version_symbol, VERSION_PLACEHOLDER};
8+
use rustc_attr::VERSION_PLACEHOLDER;
99
use rustc_hir::intravisit::Visitor;
1010
use rustc_middle::hir::nested_filter;
1111
use rustc_middle::middle::lib_features::LibFeatures;
@@ -59,7 +59,7 @@ impl<'tcx> LibFeatureCollector<'tcx> {
5959
if let Some(s) = since
6060
&& s.as_str() == VERSION_PLACEHOLDER
6161
{
62-
since = Some(rust_version_symbol());
62+
since = Some(sym::env_CFG_RELEASE);
6363
}
6464

6565
if let Some(feature) = feature {

compiler/rustc_passes/src/stability.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
44
use crate::errors;
55
use rustc_attr::{
6-
self as attr, rust_version_symbol, ConstStability, Since, Stability, StabilityLevel, Unstable,
7-
UnstableReason, VERSION_PLACEHOLDER,
6+
self as attr, ConstStability, Since, Stability, StabilityLevel, Unstable, UnstableReason,
7+
VERSION_PLACEHOLDER,
88
};
99
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
1010
use rustc_hir as hir;
@@ -1115,7 +1115,7 @@ fn unnecessary_stable_feature_lint(
11151115
mut since: Symbol,
11161116
) {
11171117
if since.as_str() == VERSION_PLACEHOLDER {
1118-
since = rust_version_symbol();
1118+
since = sym::env_CFG_RELEASE;
11191119
}
11201120
tcx.emit_spanned_lint(
11211121
lint::builtin::STABLE_FEATURES,

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ symbols! {
713713
encode,
714714
end,
715715
env,
716+
env_CFG_RELEASE: env!("CFG_RELEASE"),
716717
eprint_macro,
717718
eprintln_macro,
718719
eq,

0 commit comments

Comments
 (0)