Skip to content

PATH_BUF_PUSH_OVERWRITE lint is problematic #4012

Closed
@ghost

Description

The correctness group is for: "code that is just outright wrong or very very useless, causes hard errors by default". Pushing with overwrite is part of the API and it's useful on occasion. There is no way that you can say that all code that does it is "outright wrong".

Another big problem with this lint suggestions isn't equivalent. If people blindly follow the suggestion they will actually introduce bugs into their code.

Here is my a counter example:

use std::path::PathBuf;

let mut path = PathBuf::new();
path.push("/etc");
assert_eq!(path, PathBuf::from("/etc"));

According to the lint, this code is "outright wrong" and should be replaced by:

use std::path::PathBuf;

let mut path = PathBuf::new();
path.push("etc");
assert_eq!(path, PathBuf::from("/etc"));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions