Pre-intern a symbol for env!("CFG_RELEASE")

This commit is contained in:
David Tolnay 2023-10-25 14:05:42 -07:00
parent 5563a9ba3d
commit ac4fa3f245
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
4 changed files with 6 additions and 9 deletions

View File

@ -26,10 +26,6 @@ pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
pub const CURRENT_RUSTC_VERSION: &str = env!("CFG_RELEASE");
pub fn rust_version_symbol() -> Symbol {
Symbol::intern(CURRENT_RUSTC_VERSION)
}
pub fn is_builtin_attr(attr: &Attribute) -> bool {
attr.is_doc_comment() || attr.ident().is_some_and(|ident| is_builtin_attr_name(ident.name))
}

View File

@ -5,7 +5,7 @@
//! collect them instead.
use rustc_ast::Attribute;
use rustc_attr::{rust_version_symbol, VERSION_PLACEHOLDER};
use rustc_attr::VERSION_PLACEHOLDER;
use rustc_hir::intravisit::Visitor;
use rustc_middle::hir::nested_filter;
use rustc_middle::middle::lib_features::LibFeatures;
@ -59,7 +59,7 @@ impl<'tcx> LibFeatureCollector<'tcx> {
if let Some(s) = since
&& s.as_str() == VERSION_PLACEHOLDER
{
since = Some(rust_version_symbol());
since = Some(sym::env_CFG_RELEASE);
}
if let Some(feature) = feature {

View File

@ -3,8 +3,8 @@
use crate::errors;
use rustc_attr::{
self as attr, rust_version_symbol, ConstStability, Since, Stability, StabilityLevel, Unstable,
UnstableReason, VERSION_PLACEHOLDER,
self as attr, ConstStability, Since, Stability, StabilityLevel, Unstable, UnstableReason,
VERSION_PLACEHOLDER,
};
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
use rustc_hir as hir;
@ -1115,7 +1115,7 @@ fn unnecessary_stable_feature_lint(
mut since: Symbol,
) {
if since.as_str() == VERSION_PLACEHOLDER {
since = rust_version_symbol();
since = sym::env_CFG_RELEASE;
}
tcx.emit_spanned_lint(
lint::builtin::STABLE_FEATURES,

View File

@ -713,6 +713,7 @@ symbols! {
encode,
end,
env,
env_CFG_RELEASE: env!("CFG_RELEASE"),
eprint_macro,
eprintln_macro,
eq,