Also replace the version placeholder in rustc_attr
This fixes rustdoc not showing the current version as stabilization version for recently stabilized lang features.
This commit is contained in:
parent
0631ea5d73
commit
0c4ec5df58
3 changed files with 14 additions and 2 deletions
|
@ -15,6 +15,12 @@ use std::num::NonZeroU32;
|
||||||
|
|
||||||
use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};
|
use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};
|
||||||
|
|
||||||
|
/// The version placeholder that recently stabilized features contain inside the
|
||||||
|
/// `since` field of the `#[stable]` attribute.
|
||||||
|
///
|
||||||
|
/// For more, see [this pull request](https://github.com/rust-lang/rust/pull/100591).
|
||||||
|
pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
|
||||||
|
|
||||||
pub fn is_builtin_attr(attr: &Attribute) -> bool {
|
pub fn is_builtin_attr(attr: &Attribute) -> bool {
|
||||||
attr.is_doc_comment() || attr.ident().filter(|ident| is_builtin_attr_name(ident.name)).is_some()
|
attr.is_doc_comment() || attr.ident().filter(|ident| is_builtin_attr_name(ident.name)).is_some()
|
||||||
}
|
}
|
||||||
|
@ -483,6 +489,12 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(s) = since && s.as_str() == VERSION_PLACEHOLDER {
|
||||||
|
let version = option_env!("CFG_VERSION").unwrap_or("<current>");
|
||||||
|
let version = version.split(' ').next().unwrap();
|
||||||
|
since = Some(Symbol::intern(&version));
|
||||||
|
}
|
||||||
|
|
||||||
match (feature, since) {
|
match (feature, since) {
|
||||||
(Some(feature), Some(since)) => {
|
(Some(feature), Some(since)) => {
|
||||||
let level = Stable { since, allowed_through_unstable_modules: false };
|
let level = Stable { since, allowed_through_unstable_modules: false };
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
//! collect them instead.
|
//! collect them instead.
|
||||||
|
|
||||||
use rustc_ast::{Attribute, MetaItemKind};
|
use rustc_ast::{Attribute, MetaItemKind};
|
||||||
|
use rustc_attr::VERSION_PLACEHOLDER;
|
||||||
use rustc_errors::struct_span_err;
|
use rustc_errors::struct_span_err;
|
||||||
use rustc_hir::intravisit::Visitor;
|
use rustc_hir::intravisit::Visitor;
|
||||||
use rustc_middle::hir::nested_filter;
|
use rustc_middle::hir::nested_filter;
|
||||||
|
@ -54,7 +55,6 @@ impl<'tcx> LibFeatureCollector<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
|
|
||||||
|
|
||||||
if let Some(s) = since && s.as_str() == VERSION_PLACEHOLDER {
|
if let Some(s) = since && s.as_str() == VERSION_PLACEHOLDER {
|
||||||
let version = option_env!("CFG_VERSION").unwrap_or("<current>");
|
let version = option_env!("CFG_VERSION").unwrap_or("<current>");
|
||||||
|
|
|
@ -14,7 +14,7 @@ fn main() {
|
||||||
walk::filter_dirs(path)
|
walk::filter_dirs(path)
|
||||||
// We exempt these as they require the placeholder
|
// We exempt these as they require the placeholder
|
||||||
// for their operation
|
// for their operation
|
||||||
|| path.ends_with("compiler/rustc_passes/src/lib_features.rs")
|
|| path.ends_with("compiler/rustc_attr/src/builtin.rs")
|
||||||
|| path.ends_with("src/tools/tidy/src/features/version.rs")
|
|| path.ends_with("src/tools/tidy/src/features/version.rs")
|
||||||
|| path.ends_with("src/tools/replace-version-placeholder")
|
|| path.ends_with("src/tools/replace-version-placeholder")
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue