Skip to content

New lint: needless Path::new #14668

Open
@ada4a

Description

@ada4a

What it does

Checks whether a &str is wrapped in Path::new before being passed to a function that accepts impl AsRef<Path>. So somewhat similar to needless_borrow

Advantage

  • more concise
  • avoids the import

Drawbacks

can't think of any...

Example

std::fs::write(Path::new("foo.txt"), "foo");

Could be written as:

std::fs::write("foo.txt", "foo");

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions