Skip to content

Lint PhantomData::default() -> PhantomData #10609

@alecmocatta

Description

@alecmocatta

What it does

PhantomData::default() is quite common https://github.com/search?q=language%3ARust+%22PhantomData%3A%3Adefault%28%29%22&type=code&ref=advsearch though of course the ::default() is actually redundant.

Perhaps a lint that suggests removing the ::default() would be useful?.

Lint Name

No response

Category

style, pedantic

Advantage

Shorter, ostensibly avoids a function call.

Drawbacks

Perhaps

Foo {
    _marker: PhantomData::default()
}

makes more sense to some people than the slightly special

Foo {
    _marker: PhantomData
}

Example

Foo {
    _marker: PhantomData::default()
}

Could be written as:

Foo {
    _marker: PhantomData
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsgood 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