about summary refs log tree commit diff
path: root/compiler/rustc_expand
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2024-08-28 00:00:08 +0200
committerest31 <MTest31@outlook.com>2024-10-05 04:29:46 +0200
commit00ed47b8496bacb9da0196127508e07ba5d14bb4 (patch)
tree477b4645e08fa330958ec018e0340b92cd45ebe1 /compiler/rustc_expand
parent4428a051679ec6194a118424f4616d922249a1e6 (diff)
downloadrust-00ed47b8496bacb9da0196127508e07ba5d14bb4.tar.gz
rust-00ed47b8496bacb9da0196127508e07ba5d14bb4.zip
Make deprecated_cfg_attr_crate_type_name a hard error
Diffstat (limited to 'compiler/rustc_expand')
-rw-r--r--compiler/rustc_expand/messages.ftl6
-rw-r--r--compiler/rustc_expand/src/config.rs19
-rw-r--r--compiler/rustc_expand/src/errors.rs14
3 files changed, 25 insertions, 14 deletions
diff --git a/compiler/rustc_expand/messages.ftl b/compiler/rustc_expand/messages.ftl
index 766d96e268f..57bac9d09d5 100644
--- a/compiler/rustc_expand/messages.ftl
+++ b/compiler/rustc_expand/messages.ftl
@@ -27,6 +27,12 @@ expand_collapse_debuginfo_illegal =
 expand_count_repetition_misplaced =
     `count` can not be placed inside the inner-most repetition
 
+expand_crate_name_in_cfg_attr =
+    `crate_name` within an `#![cfg_attr]` attribute is forbidden
+
+expand_crate_type_in_cfg_attr =
+    `crate_type` within an `#![cfg_attr]` attribute is forbidden
+
 expand_custom_attribute_panicked =
     custom attribute panicked
     .help = message: {$message}
diff --git a/compiler/rustc_expand/src/config.rs b/compiler/rustc_expand/src/config.rs
index 32088374277..7bd4372d186 100644
--- a/compiler/rustc_expand/src/config.rs
+++ b/compiler/rustc_expand/src/config.rs
@@ -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
     }
diff --git a/compiler/rustc_expand/src/errors.rs b/compiler/rustc_expand/src/errors.rs
index 0fdccb08918..5682c574552 100644
--- a/compiler/rustc_expand/src/errors.rs
+++ b/compiler/rustc_expand/src/errors.rs
@@ -468,6 +468,20 @@ pub(crate) struct GlobDelegationOutsideImpls {
 }
 
 #[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 {
     #[primary_span]