RS.CLIPPY.USE_SELF

Unnecessary structure name repetition whereas `Self` is applicable

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

What it does

Checks for unnecessary repetition of structure name when a replacement with Self is applicable.

Why is this bad?

Unnecessary repetition. Mixed use of Self and struct name feels inconsistent.

Known problems

  • Unaddressed false negative in fn bodies of trait implementations

Example

struct Foo;
impl Foo {
    fn new() -> Foo {
        Foo {}
    }
}

could be

struct Foo;
impl Foo {
    fn new() -> Self {
        Self {}
    }
}

Configuration

  • msrv: The minimum rust version that the project supports. Defaults to the rust-version field in Cargo.toml

    (default: current version)