nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: JelteF/derive_more
Pull request #384 (2024-07-04 21:45:09)

Fix TryInto derive for generics
Part of #335

## Synopsis

Our `TryFrom` derive would fail when the type had any generics, this was a bug introduced with our changes for 1.0.

## Solution

This fixes that by correctly adding the generic parameters to the `Error` type of `TryFrom`.

## Checklist

- [x] Tests are added/updated (if required)



Patch:
diff --git a/impl/src/try_into.rs b/impl/src/try_into.rs
index 4647827..a2ebce8 100644
--- a/impl/src/try_into.rs
+++ b/impl/src/try_into.rs
@@ -104,7 +104,7 @@ pub fn expand(input: &DeriveInput, trait_name: &'static str) -> Result<TokenStre
             impl #impl_generics derive_more::core::convert::TryFrom<
                 #reference_with_lifetime #input_type #ty_generics
             > for (#(#reference_with_lifetime #original_types),*) #where_clause {
-                type Error = derive_more::TryIntoError<#reference_with_lifetime #input_type>;
+                type Error = derive_more::TryIntoError<#reference_with_lifetime #input_type #ty_generics>;
 
                 #[inline]
                 fn try_from(


Test patch:
diff --git a/tests/generics.rs b/tests/generics.rs
index bf968eb..42c568a 100644
--- a/tests/generics.rs
+++ b/tests/generics.rs
@@ -3,7 +3,7 @@
 
 use derive_more::{
     Add, AddAssign, Constructor, Deref, DerefMut, Display, Error, From, FromStr, Index,
-    IndexMut, IntoIterator, Mul, MulAssign, Not, Sum,
+    IndexMut, IntoIterator, Mul, MulAssign, Not, Sum, TryInto,
 };
 
 #[derive(
@@ -262,3 +262,11 @@ struct StructLifetimeGenericBoundsConstDefault<
 > {
     inner: &'lt E,
 }
+
+#[derive(Debug, Display)]
+struct Wrapper<'a, const Y: usize, U>(&'a [U; Y]);
+
+#[derive(Debug, Display, TryInto)]
+enum Foo<'lt: 'static, T: Clone, const X: usize> {
+    X(Wrapper<'lt, X, T>),
+}
diff --git a/tests/try_into.rs b/tests/try_into.rs
index 37485ef..95b510e 100644
--- a/tests/try_into.rs
+++ b/tests/try_into.rs
@@ -40,6 +40,13 @@ enum MixedInts {
     Unit2,
 }
 
+#[derive(Clone, Copy, Debug, Eq, PartialEq)]
+struct Wrapper<'a, const Y: usize, U>(&'a [U; Y]);
+
+enum Foo<'lt: 'static, T: Clone, const X: usize> {
+    X(Wrapper<'lt, X, T>),
+}
+
 #[test]
 fn test_try_into() {
     let mut i = MixedInts::SmallInt(42);
Repository: JelteF/derive_more
Pull request #477 (2025-05-29 20:06:23)

Add attribute too_many_arguments to the new method for Construct
Resolves https://github.com/JelteF/derive_more/issues/397

## Synopsis

Clippy emits a too_many_arguments warning for the new method generated by the Constructor derive.
Clippy attributes currently have no effect in this context.

## Solution

Add #[allow(clippy::too_many_arguments)] to the generated new method to suppress the warning without affecting other code.


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6cf9a95..0b0f9f4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
   ([#469](https://github.com/JelteF/derive_more/pull/469))
 - Add `PartialEq` derive similar to `std`'s one, but considering generics correctly.
   ([#473](https://github.com/JelteF/derive_more/pull/473))
+- Proxy-pass `#[allow]`/`#[expect]` attributes of the type in `Constructor` derive.
+  ([#477](https://github.com/JelteF/derive_more/pull/477))
 
 ### Changed
 
diff --git a/impl/src/constructor.rs b/impl/src/constructor.rs
index 7f30aea..2ea2612 100644
--- a/impl/src/constructor.rs
+++ b/impl/src/constructor.rs
@@ -23,11 +23,19 @@ pub fn expand(input: &DeriveInput, _: &str) -> TokenStream {
         },
         _ => panic!("Only structs can derive a constructor"),
     };
+
+    let inherited_lint_attrs = input.attrs.iter().filter(|attr| {
+        attr.path()
+            .get_ident()
+            .is_some_and(|name| name == "allow" || name == "expect")
+    });
+
     let original_types = &get_field_types(&fields);
     quote! {
-        #[allow(deprecated)] // omit warnings on deprecated fields/variants
+        #[allow(deprecated)]       // omit warnings on deprecated fields/variants
         #[allow(missing_docs)]
         #[allow(unreachable_code)] // omit warnings for `!` and other unreachable types
+        #(#inherited_lint_attrs)*  // proxy-pass any `#[allow]`/`#[expect]` attributes
         #[automatically_derived]
         impl #impl_generics #input_type #ty_generics #where_clause {
             #[inline]


Test patch:
diff --git a/tests/constructor.rs b/tests/constructor.rs
index a25b2c8..b1af19a 100644
--- a/tests/constructor.rs
+++ b/tests/constructor.rs
@@ -68,3 +68,38 @@ mod deprecated {
         field: i32,
     }
 }
+
+mod proxy_lint_attr {
+    #![deny(non_snake_case, clippy::too_many_arguments)]
+
+    use super::*;
+
+    #[allow(clippy::too_many_arguments)]
+    #[derive(Constructor)]
+    struct ManyArguments(
+        u8,
+        u8,
+        u8,
+        u8,
+        u8,
+        u8,
+        u8,
+        u8,
+        u8,
+        u8,
+        u8,
+        u8,
+        u8,
+        u8,
+        u8,
+        u8,
+        u8,
+        u8,
+    );
+
+    #[expect(non_snake_case)]
+    #[derive(Constructor)]
+    struct User {
+        Num: i32,
+    }
+}