overhaul unnecessary_map_or#16383
Conversation
|
rustbot has assigned @samueltardieu. Use |
|
Lintcheck changes for 24e45b7
This comment will be updated if you push new changes |
aeb1902 to
9780bdb
Compare
to make sure that each commit builds in isolation
NOTE: the changes to `map_unwrap_or_fixable` can't be moved to the dogfood commit, as at that point `needless_is_variant_and` is still an unknown lint
9780bdb to
24e45b7
Compare
|
Those commits (except the dogfood one of course) should be separate PRs that can be judged on their own merit, especially if checks are moved from one lint to another and if a new lint is introduced. Just make PR 3 depend on PR 1 and 2, and PR 4 (commits 4 and 5) depend on PR 3 if required, or PR 1 and 2 otherwise. |
|
Yeah fair enough.. Though I'm not sure the first commit really deserves to be its own PR? It's just a bunch of clean-up.. |
…which have to be reviewed anyhow. The second commit can get approved much faster IMO in isolation. |
|
Opened the sub-PRs, see the mentions above this comment |
This is the first commit of #16383 changelog: none
Third commit moves
.map_or(false,->.is_some_and(and similar transformations tomanual_is_variant_andx.map_or(true, |n| n > 5)tomanual_is_variant_and#15998, resolves Splittingunnecessary_map_orinto 2 lints #15999.Fourth and fifth commits add a new lint,
needless_is_variant_and, which transforms.is_some_and(|n| n == 5)into== Some(5)== Some(foris_some_andif possible #14713unnecessary_map_orFor further reasoning, please see the documentation on
manual_eq_optional.rs.Diffs best viewed with whitespace ignored and
--color-movedcc @teofr
changelog: [
unnecessary_map_or]: move.map_or(false,->.is_some_and(and similar transformations tomanual_is_variant_andchangelog: [
needless_is_variant_and]: new lint