Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PATH_BUF_PUSH_OVERWRITE lint is problematic #4012

Closed
ghost opened this issue Apr 21, 2019 · 2 comments
Closed

PATH_BUF_PUSH_OVERWRITE lint is problematic #4012

ghost opened this issue Apr 21, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Apr 21, 2019

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"));
@Manishearth
Copy link
Member

Agreed. If clear() were stable it might make sense to recommend that instead (but not always -- it's still useful to push absolutes on Windows).

I'd move this to nursery

kraai added a commit to kraai/rust-clippy that referenced this issue Apr 21, 2019
kraai added a commit to kraai/rust-clippy that referenced this issue Apr 21, 2019
kraai added a commit to kraai/rust-clippy that referenced this issue Apr 21, 2019
kraai added a commit to kraai/rust-clippy that referenced this issue Apr 21, 2019
kraai added a commit to kraai/rust-clippy that referenced this issue Apr 21, 2019
bors added a commit that referenced this issue Apr 21, 2019
…r=matthiaskrgr

Move path_buf_push_overwrite to nursery

See #4012.

changelog: move `path_buf_push_overwrite` to the nursery
@ghost
Copy link
Author

ghost commented Jun 30, 2019

The lint was moved to nursery.

@ghost ghost closed this as completed Jun 30, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant