Rollup merge of #101772 - est31:replace_placeholder_diagnostics, r=jackh726
Also replace the placeholder for the stable_features lint Follow up of #101215 and #100591 . Fixes #101766
This commit is contained in:
commit
94bc08d94f
3 changed files with 20 additions and 9 deletions
|
@ -21,6 +21,12 @@ use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};
|
||||||
/// For more, see [this pull request](https://github.com/rust-lang/rust/pull/100591).
|
/// For more, see [this pull request](https://github.com/rust-lang/rust/pull/100591).
|
||||||
pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
|
pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
|
||||||
|
|
||||||
|
pub fn rust_version_symbol() -> Symbol {
|
||||||
|
let version = option_env!("CFG_VERSION").unwrap_or("<current>");
|
||||||
|
let version = version.split(' ').next().unwrap();
|
||||||
|
Symbol::intern(&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()
|
||||||
}
|
}
|
||||||
|
@ -495,9 +501,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
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>");
|
since = Some(rust_version_symbol());
|
||||||
let version = version.split(' ').next().unwrap();
|
|
||||||
since = Some(Symbol::intern(&version));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match (feature, since) {
|
match (feature, since) {
|
||||||
|
|
|
@ -5,7 +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_attr::{rust_version_symbol, 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;
|
||||||
|
@ -57,9 +57,7 @@ impl<'tcx> LibFeatureCollector<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
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>");
|
since = Some(rust_version_symbol());
|
||||||
let version = version.split(' ').next().unwrap();
|
|
||||||
since = Some(Symbol::intern(&version));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(feature) = feature {
|
if let Some(feature) = feature {
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
//! propagating default levels lexically from parent to children ast nodes.
|
//! propagating default levels lexically from parent to children ast nodes.
|
||||||
|
|
||||||
use rustc_attr::{
|
use rustc_attr::{
|
||||||
self as attr, ConstStability, Stability, StabilityLevel, Unstable, UnstableReason,
|
self as attr, rust_version_symbol, ConstStability, Stability, StabilityLevel, Unstable,
|
||||||
|
UnstableReason, VERSION_PLACEHOLDER,
|
||||||
};
|
};
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
||||||
use rustc_errors::{struct_span_err, Applicability};
|
use rustc_errors::{struct_span_err, Applicability};
|
||||||
|
@ -1106,7 +1107,15 @@ fn unnecessary_partially_stable_feature_lint(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unnecessary_stable_feature_lint(tcx: TyCtxt<'_>, span: Span, feature: Symbol, since: Symbol) {
|
fn unnecessary_stable_feature_lint(
|
||||||
|
tcx: TyCtxt<'_>,
|
||||||
|
span: Span,
|
||||||
|
feature: Symbol,
|
||||||
|
mut since: Symbol,
|
||||||
|
) {
|
||||||
|
if since.as_str() == VERSION_PLACEHOLDER {
|
||||||
|
since = rust_version_symbol();
|
||||||
|
}
|
||||||
tcx.struct_span_lint_hir(lint::builtin::STABLE_FEATURES, hir::CRATE_HIR_ID, span, |lint| {
|
tcx.struct_span_lint_hir(lint::builtin::STABLE_FEATURES, hir::CRATE_HIR_ID, span, |lint| {
|
||||||
lint.build(&format!(
|
lint.build(&format!(
|
||||||
"the feature `{feature}` has been stable since {since} and no longer requires an \
|
"the feature `{feature}` has been stable since {since} and no longer requires an \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue