Commit 1a815f6 authored Sep 2, 2022 Verified
File tree 3 files changed +14
-2
lines changed
src/tools/replace-version-placeholder/src
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;
15
15
16
16
use crate :: session_diagnostics:: { self , IncorrectReprFormatGenericCause } ;
17
17
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
+
18
24
pub fn is_builtin_attr ( attr : & Attribute ) -> bool {
19
25
attr. is_doc_comment ( ) || attr. ident ( ) . filter ( |ident| is_builtin_attr_name ( ident. name ) ) . is_some ( )
20
26
}
@@ -483,6 +489,12 @@ where
483
489
}
484
490
}
485
491
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
+
486
498
match ( feature, since) {
487
499
( Some ( feature) , Some ( since) ) => {
488
500
let level = Stable { since, allowed_through_unstable_modules : false } ;
Original file line number Diff line number Diff line change 5
5
//! collect them instead.
6
6
7
7
use rustc_ast:: { Attribute , MetaItemKind } ;
8
+ use rustc_attr:: VERSION_PLACEHOLDER ;
8
9
use rustc_errors:: struct_span_err;
9
10
use rustc_hir:: intravisit:: Visitor ;
10
11
use rustc_middle:: hir:: nested_filter;
@@ -54,7 +55,6 @@ impl<'tcx> LibFeatureCollector<'tcx> {
54
55
}
55
56
}
56
57
}
57
- const VERSION_PLACEHOLDER : & str = "CURRENT_RUSTC_VERSION" ;
58
58
59
59
if let Some ( s) = since && s. as_str ( ) == VERSION_PLACEHOLDER {
60
60
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() {
14
14
walk:: filter_dirs ( path)
15
15
// We exempt these as they require the placeholder
16
16
// for their operation
17
- || path. ends_with ( "compiler/rustc_passes /src/lib_features .rs" )
17
+ || path. ends_with ( "compiler/rustc_attr /src/builtin .rs" )
18
18
|| path. ends_with ( "src/tools/tidy/src/features/version.rs" )
19
19
|| path. ends_with ( "src/tools/replace-version-placeholder" )
20
20
} ,
You can’t perform that action at this time.
0 commit comments