3344: Added lints `into_iter_on_ref` and `into_iter_on_array`. r=phansch a=kennytm
Fixes#1565.
`into_iter_on_array` is a correctness lint against `into_iter()` on `[T; n]` and `PathBuf` (please provide a concise noun that covers both types 🙃).
`into_iter_on_ref` is a style lint against `into_iter()` on `&C` where `C` is `[T]`, `Vec<T>`, `BTreeSet<T>` etc.
Both suggests replacing the `into_iter()` with `iter()` or `iter_mut()`.
`into_iter_on_array` is a correctness lint since it is very likely the standard library would provide an `into_iter()` method for `[T; n]` (rust-lang/rust#25725) and existing type inference of `[a, b, c].into_iter()` will be broken. `PathBuf` is also placed under this lint since `PathBuf::into_iter` currently doesn't exist and it makes some sense to implement `IntoIterator` on it yielding `OsString`s.
Co-authored-by: kennytm <kennytm@gmail.com>
3161: New lint: Unknown clippy lints r=phansch a=flip1995
This is the Clippy version of the `rustc` lint `unknown_lints`. The behavior of this lint is pretty much the same.
Before this is merged a small change in the compiler needs to be done: `CheckLintNameResult` needs to be public. See rust-lang/rust#54106
Co-authored-by: flip1995 <9744647+flip1995@users.noreply.github.com>
Co-authored-by: flip1995 <hello@philkrones.com>
3402: clippy: fix pedantic warnings and run clippy::pedantic lints on the codebase r=oli-obk a=matthiaskrgr
Turn on pedantic lints in dogfood and base tests.
needless_bool: fix clippy::items-after-statements
redundant_pattern_matching: fix clippy::similar-names
mods.rs: fix clippy::explicit-iter-loop
returns.rs: allow clippy::cast-possible-wrap
Fixes#3172
Co-authored-by: Matthias Krüger <matthias.krueger@famsik.de>
3397: UI test cleanup: Extract expect_fun_call tests r=matthiaskrgr a=phansch
Note that the new stderr file does not include a `shadow-unrelated`
error, because the new UI test file does not use `#![warn(clippy::all)]`
cc #2038
3398: UI test cleanup: Extract match_overlapping_arm tests r=matthiaskrgr a=phansch
cc #2038
Co-authored-by: Philipp Hansch <dev@phansch.net>
3388: RIIR update lints: Generate deprecated lints r=phansch a=phansch
The update script now also generates the 'register_removed' section in
`clippy_lints/src/lib.rs`.
Also, instead of using `let mut store ...`, I added a new identifier
line so that the replacement will continue to work in case `let mut
store ...` ever changes.
cc #2882
Co-authored-by: Philipp Hansch <dev@phansch.net>
3389: ci: when installing rust-toolchain-installer-master, install it in debug mode to save some time on ci. r=phansch a=matthiaskrgr
the compiletime optimizations probably take longer than the speedup we get when executing the optimized binary vs debug build.
Co-authored-by: Matthias Krüger <matthias.krueger@famsik.de>
3368: added downsides to "known problems" for get_unwrap lint r=flip1995 a=humean
As a beginner I found this lint to be confusing because I was not sure how the `Option` type disappeared as conceptually I know that my `.get()` and Index could fail. Initially I thought maybe the compiler or clippy was smart enough to understand that it was impossible for my `.get()` to fail in this particular case, but it was explained to me that using the Index syntax is just shorthand for directly unwrapping the value:
https://doc.rust-lang.org/src/std/collections/hash/map.rs.html#1547
For beginners or users trying to iterate quickly it seems common to litter your code with `unwrap` or `except` as placeholders for where some explicit error handling might need to take place. I think it should be warned that using Index is merely more concise, but doesn't at all reduce the risk of panics and might in fact cause you to miss handling them in a future refactor.
Co-authored-by: Michael Rutter <michael.john.rutter@gmail.com>
Co-authored-by: Michael Rutter <humean@users.noreply.github.com>
The update script now also generates the 'register_removed' section in
`clippy_lints/src/lib.rs`.
Also, instead of using `let mut store ...`, I added a new identifier
line so that the replacement will continue to work in case `let mut
store ...` ever changes.