Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy attributes doesn't work with Constructor #397

Open
tokarevvit opened this issue Aug 12, 2024 · 1 comment
Open

Clippy attributes doesn't work with Constructor #397

tokarevvit opened this issue Aug 12, 2024 · 1 comment

Comments

@tokarevvit
Copy link

For example when tried to apply #[allow(clippy::too_many_arguments)] it has no effect.
But it works for Debug.

use derive_more::Constructor;

#[allow(clippy::too_many_arguments)]
#[derive(Debug, Constructor)]
struct Test{
    a: u64,
    b: u64,
    c: u64,
    d: u64,
    e: u64,
    f: u64,
    g: u64,
    h: u64,
    i: u64
}

fn main() {
    let test = Test::new(1,2,3,4,5,6,7,8,9);

    println!("{:?}", test);
}

cargo expand output:

#![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;
use derive_more::Constructor;
#[allow(clippy::too_many_arguments)]
struct Test {
    a: u64,
    b: u64,
    c: u64,
    d: u64,
    e: u64,
    f: u64,
    g: u64,
    h: u64,
    i: u64,
}
#[automatically_derived]
#[allow(clippy::too_many_arguments)]
impl ::core::fmt::Debug for Test {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ = &["a", "b", "c", "d", "e", "f", "g", "h", "i"];
        let values: &[&dyn ::core::fmt::Debug] = &[
            &self.a, &self.b, &self.c, &self.d, &self.e, &self.f, &self.g, &self.h, &&self.i,
        ];
        ::core::fmt::Formatter::debug_struct_fields_finish(f, "Test", names, values)
    }
}
#[allow(missing_docs)]
#[automatically_derived]
impl Test {
    #[inline]
    pub const fn new(
        a: u64,
        b: u64,
        c: u64,
        d: u64,
        e: u64,
        f: u64,
        g: u64,
        h: u64,
        i: u64,
    ) -> Test {
        Test {
            a: a,
            b: b,
            c: c,
            d: d,
            e: e,
            f: f,
            g: g,
            h: h,
            i: i,
        }
    }
}
fn main() {
    let test = Test::new(1, 2, 3, 4, 5, 6, 7, 8, 9);
    {
        ::std::io::_print(format_args!("{0:?}\n", test));
    };
}
@JelteF
Copy link
Owner

JelteF commented Sep 8, 2024

Yeah makes sense, I would accept a fix for this issue. I think the easiest is to always add this #[allow] to the constructor field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants