Add Lint PathBufPushOverwrite
Closes#3923
This is a very simple Lint that checks if push is being called with a Root Path. Because that can make it overwrite the previous path.
I used std::path::Path to check if it's root, in order to keep it working across windows/linux environments instead of checking for '/'. Is that alright?
On the `if_chain!` block, Is there a way to make it short while getting the value of the first argument? I got the example from other lints.
Note that this is first Lint, I hope I got everything covered 🚀
Add run-rustfix for option_map_or_none lint
* Extracts `option_map_or_none` tests into separate file
* Adds `// run-rustfix` to `tests/ui/option_map_or_none.rs`
cc #3630
Change naive_bytecount applicability to MaybeIncorrect
We can't use `MachineApplicable` here as applying the fix will cause
another error because `bytecount` would first have to be added to the
Cargo.toml.
Example:
```
error: You appear to be counting bytes the naive way
--> $DIR/bytecount.rs:5:13
|
LL | let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider using the bytecount crate: `bytecount::count(x, 0)`
```
Just replacing it with the suggestion is not enough.
cc #3630
Add run-rustfix for deref_addrof lint
* renames `tests/ui/reference.{rs,stderr}` to
`tests/ui/deref_addrof.{rs,stderr}
* Moves small part of the testfile to a separate file as the lint
triggered again on the fixed code (as intended)
* Adds `// run-rustfix` to `tests/ui/deref_addrof.rs`
cc #3630
Change while_let_loop applicability to HasPlaceholders
The suggestion has been changed at some point to use `..` in the suggested code.
Due to that we can't make the lint MachineApplicable anymore.
cc #3630
* renames `tests/ui/reference.{rs,stderr}` to
`tests/ui/deref_addrof.{rs,stderr}
* Moves small part of the testfile to a separate file as the lint
triggered again on the fixed code (as intended)
* Adds `// run-rustfix` to `tests/ui/deref_addrof.rs`
Suggest .copied() instead of .cloned() in map_clone where applicable
partial fix for https://github.com/rust-lang/rust-clippy/issues/3958
changelog: Improve suggestion in `map_clone` to suggest `.copied()` where applicable