File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed
src/tools/replace-version-placeholder/src Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,12 @@ use std::num::NonZeroU32;
1515
1616use crate :: session_diagnostics:: { self , IncorrectReprFormatGenericCause } ;
1717
18+ /// The version placeholder that recently stabilized features contain inside the
19+ /// `since` field of the `#[stable]` attribute.
20+ ///
21+ /// For more, see [this pull request](https://github.com/rust-lang/rust/pull/100591).
22+ pub const VERSION_PLACEHOLDER : & str = "CURRENT_RUSTC_VERSION" ;
23+
1824pub fn is_builtin_attr ( attr : & Attribute ) -> bool {
1925 attr. is_doc_comment ( ) || attr. ident ( ) . filter ( |ident| is_builtin_attr_name ( ident. name ) ) . is_some ( )
2026}
@@ -483,6 +489,12 @@ where
483489 }
484490 }
485491
492+ if let Some ( s) = since && s. as_str ( ) == VERSION_PLACEHOLDER {
493+ let version = option_env ! ( "CFG_VERSION" ) . unwrap_or ( "<current>" ) ;
494+ let version = version. split ( ' ' ) . next ( ) . unwrap ( ) ;
495+ since = Some ( Symbol :: intern ( & version) ) ;
496+ }
497+
486498 match ( feature, since) {
487499 ( Some ( feature) , Some ( since) ) => {
488500 let level = Stable { since, allowed_through_unstable_modules : false } ;
Original file line number Diff line number Diff line change 55//! collect them instead.
66
77use rustc_ast:: { Attribute , MetaItemKind } ;
8+ use rustc_attr:: VERSION_PLACEHOLDER ;
89use rustc_errors:: struct_span_err;
910use rustc_hir:: intravisit:: Visitor ;
1011use rustc_middle:: hir:: nested_filter;
@@ -54,7 +55,6 @@ impl<'tcx> LibFeatureCollector<'tcx> {
5455 }
5556 }
5657 }
57- const VERSION_PLACEHOLDER : & str = "CURRENT_RUSTC_VERSION" ;
5858
5959 if let Some ( s) = since && s. as_str ( ) == VERSION_PLACEHOLDER {
6060 let version = option_env ! ( "CFG_VERSION" ) . unwrap_or ( "<current>" ) ;
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ fn main() {
1414 walk:: filter_dirs ( path)
1515 // We exempt these as they require the placeholder
1616 // for their operation
17- || path. ends_with ( "compiler/rustc_passes /src/lib_features .rs" )
17+ || path. ends_with ( "compiler/rustc_attr /src/builtin .rs" )
1818 || path. ends_with ( "src/tools/tidy/src/features/version.rs" )
1919 || path. ends_with ( "src/tools/replace-version-placeholder" )
2020 } ,
You can’t perform that action at this time.
0 commit comments