Skip to content

Collapse new_without_default and new_without_default_derive into a single lint #3525

Closed
@dtolnay

Description

@dtolnay

In code that wants to suppress new_without_default, but which uses a mix of types only some of which could derive Default, it is annoying to have to suppress both of these lint names. I consider them effectively the same lint.

I would like to propose deprecating new_without_default_derive and having new_without_default lint all the cases that used to be linted by new_without_default_derive. The cases that can derive Default should retain the help message that mentions deriving Default.

The way to think about this is: if a codebase wants to have new functions without necessarily having Default impls, then it won't matter to them whether or not Default can be derived. They would just suppress both lints. Every additional lint that they find needs to be suppressed detracts from their impression of Clippy.

#![allow(clippy::new_without_default, clippy::new_without_default_derive)]

pub struct S1;

pub struct S2(*const u8);

impl S1 {
    pub fn new() -> Self {
        S1
    }
}

impl S2 {
    pub fn new() -> Self {
        S2(0 as _)
    }
}

clippy 0.0.212 (29bf75c 2018-12-05)

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions