1
Fork 0

Make deprecated_cfg_attr_crate_type_name a hard error

This commit is contained in:
est31 2024-08-28 00:00:08 +02:00
parent 4428a05167
commit 00ed47b849
12 changed files with 60 additions and 118 deletions

View file

@ -21,8 +21,9 @@ use thin_vec::ThinVec;
use tracing::instrument;
use crate::errors::{
FeatureNotAllowed, FeatureRemoved, FeatureRemovedReason, InvalidCfg, MalformedFeatureAttribute,
MalformedFeatureAttributeHelp, RemoveExprNotSupported,
CrateNameInCfgAttr, CrateTypeInCfgAttr, FeatureNotAllowed, FeatureRemoved,
FeatureRemovedReason, InvalidCfg, MalformedFeatureAttribute, MalformedFeatureAttributeHelp,
RemoveExprNotSupported,
};
/// A folder that strips out items that do not belong in the current configuration.
@ -358,20 +359,10 @@ impl<'a> StripUnconfigured<'a> {
item_span,
);
if attr.has_name(sym::crate_type) {
self.sess.psess.buffer_lint(
rustc_lint_defs::builtin::DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME,
attr.span,
ast::CRATE_NODE_ID,
BuiltinLintDiag::CrateTypeInCfgAttr,
);
self.sess.dcx().emit_err(CrateTypeInCfgAttr { span: attr.span });
}
if attr.has_name(sym::crate_name) {
self.sess.psess.buffer_lint(
rustc_lint_defs::builtin::DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME,
attr.span,
ast::CRATE_NODE_ID,
BuiltinLintDiag::CrateNameInCfgAttr,
);
self.sess.dcx().emit_err(CrateNameInCfgAttr { span: attr.span });
}
attr
}

View file

@ -467,6 +467,20 @@ pub(crate) struct GlobDelegationOutsideImpls {
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(expand_crate_name_in_cfg_attr)]
pub(crate) struct CrateNameInCfgAttr {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(expand_crate_type_in_cfg_attr)]
pub(crate) struct CrateTypeInCfgAttr {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(expand_glob_delegation_traitless_qpath)]
pub(crate) struct GlobDelegationTraitlessQpath {