Skip to content

Commit 1a815f6

Browse files
authoredSep 2, 2022
Rollup merge of rust-lang#101215 - est31:rustdoc_version_placeholder, r=Mark-Simulacrum
Also replace the version placeholder in rustc_attr Replace the version placeholder with the current version in the rustc_attr crate too so that users won't see the placeholder but instead the explicit version. This especially fixes the bug for rustdoc not showing it but instead the placeholder. Originally reported [here](https://rust-lang.zulipchat.com/#narrow/stream/241545-t-release/topic/libs.20stabilization.20placeholder/near/296057188). cc rust-lang#100591 ![Screenshot_20220830_233727](https://user-images.githubusercontent.com/8872119/187548079-6207776b-4481-4351-afff-607f5b3fe03a.png)
2 parents 3a60cbd + 0c4ec5d commit 1a815f6

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed
 

‎compiler/rustc_attr/src/builtin.rs

+12
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ use std::num::NonZeroU32;
1515

1616
use 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+
1824
pub 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 };

‎compiler/rustc_passes/src/lib_features.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//! collect them instead.
66
77
use rustc_ast::{Attribute, MetaItemKind};
8+
use rustc_attr::VERSION_PLACEHOLDER;
89
use rustc_errors::struct_span_err;
910
use rustc_hir::intravisit::Visitor;
1011
use 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>");

‎src/tools/replace-version-placeholder/src/main.rs

+1-1
Original file line numberDiff line numberDiff 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
},

0 commit comments

Comments
 (0)
Please sign in to comment.