RS.CLIPPY.SELF_NAMED_CONSTRUCTORS

Method should not have the same name as the type it is implemented for

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: self_named_constructors. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Warns when constructors have the same name as their types.

Why is this bad?

Repeating the name of the type is redundant.

Example

struct Foo {}

impl Foo {
    pub fn foo() -> Foo {
        Foo {}
    }
}

Use instead:

struct Foo {}

impl Foo {
    pub fn new() -> Foo {
        Foo {}
    }
}