Expand the version placeholder to the current version in stability attribute parsing

That way, the current version is shown in rustdoc etc.
This commit is contained in:
est31 2022-08-15 17:28:43 +02:00
parent d06e0e53eb
commit 7a5b1d7939

View File

@ -54,6 +54,14 @@ fn extract(&self, attr: &Attribute) -> Option<(Symbol, Option<Symbol>, Span)> {
} }
} }
} }
const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
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));
}
if let Some(feature) = feature { if let Some(feature) = feature {
// This additional check for stability is to make sure we // This additional check for stability is to make sure we
// don't emit additional, irrelevant errors for malformed // don't emit additional, irrelevant errors for malformed