about summary refs log tree commit diff
path: root/compiler/rustc_attr_parsing/src/attributes/mod.rs
diff options
context:
space:
mode:
authorJonathan Dönszelmann <jonathan@donsz.nl>2025-02-06 17:36:34 +0100
committerJana Dönszelmann <jana@donsz.nl>2025-06-12 09:42:45 +0200
commit4e1b6d13a20e5b72922f085fb4b248848ca02910 (patch)
tree6a1dbf767df3f01cc47102fd4666b5ff1f1d3046 /compiler/rustc_attr_parsing/src/attributes/mod.rs
parent28bf61b9b32a2db0a9a7f32d75349b4e0db72201 (diff)
downloadrust-4e1b6d13a20e5b72922f085fb4b248848ca02910.tar.gz
rust-4e1b6d13a20e5b72922f085fb4b248848ca02910.zip
Start using new diagnostic logic on all existing `single` parsers
Diffstat (limited to 'compiler/rustc_attr_parsing/src/attributes/mod.rs')
-rw-r--r--compiler/rustc_attr_parsing/src/attributes/mod.rs28
1 files changed, 4 insertions, 24 deletions
diff --git a/compiler/rustc_attr_parsing/src/attributes/mod.rs b/compiler/rustc_attr_parsing/src/attributes/mod.rs
index 7aac4744504..852615b4fce 100644
--- a/compiler/rustc_attr_parsing/src/attributes/mod.rs
+++ b/compiler/rustc_attr_parsing/src/attributes/mod.rs
@@ -84,28 +84,8 @@ pub(crate) trait AttributeParser: Default + 'static {
 pub(crate) trait SingleAttributeParser: 'static {
     const PATH: &'static [Symbol];
 
-<<<<<<< Conflict 1 of 1
-+++++++ Contents of side #1
-    /// Called when a duplicate attribute is found.
-%%%%%%% Changes from base to side #2
-+    const ON_DUPLICATE_STRATEGY: AttributeDuplicates;
-+
-     /// Caled when a duplicate attribute is found.
->>>>>>> Conflict 1 of 1 ends
-    ///
-    /// - `unused` is the span of the attribute that was unused or bad because of some
-    ///   duplicate reason (see [`AttributeDuplicates`])
-    /// - `used` is the span of the attribute that was used in favor of the unused attribute
-    // FIXME(jdonszelmann): default error
-    fn on_duplicate(cx: &AcceptContext<'_>, used: Span, unused: Span) {
-        cx.emit_err(UnusedMultiple {
-            this: used,
-            other: unused,
-            name: Symbol::intern(
-                &Self::PATH.into_iter().map(|i| i.to_string()).collect::<Vec<_>>().join(".."),
-            ),
-        });
-    }
+    const ON_DUPLICATE_STRATEGY: AttributeDuplicates;
+    const ON_DUPLICATE: OnDuplicate;
 
     /// Converts a single syntactical attribute to a single semantic attribute, or [`AttributeKind`]
     fn convert(cx: &AcceptContext<'_>, args: &ArgParser<'_>) -> Option<AttributeKind>;
@@ -126,7 +106,7 @@ impl<T: SingleAttributeParser> AttributeParser for Single<T> {
                 // keep the first and error
                 AttributeDuplicates::ErrorFollowing => {
                     if let Some((_, unused)) = group.1 {
-                        T::on_duplicate(cx, cx.attr_span, unused);
+                        T::ON_DUPLICATE.exec::<T>(cx, cx.attr_span, unused);
                         return;
                     }
                 }
@@ -134,7 +114,7 @@ impl<T: SingleAttributeParser> AttributeParser for Single<T> {
                 // then replace
                 AttributeDuplicates::FutureWarnPreceding => {
                     if let Some((_, used)) = group.1 {
-                        T::on_duplicate(cx, used, cx.attr_span);
+                        T::ON_DUPLICATE.exec::<T>(cx, used, cx.attr_span);
                     }
                 }
             }