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

Deprecate redundant lint option_map_or_err_ok and take manual_ok_or out of pedantic #14027

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion clippy_lints/src/declared_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ pub static LINTS: &[&crate::LintInfo] = &[
crate::methods::OPTION_AS_REF_CLONED_INFO,
crate::methods::OPTION_AS_REF_DEREF_INFO,
crate::methods::OPTION_FILTER_MAP_INFO,
crate::methods::OPTION_MAP_OR_ERR_OK_INFO,
crate::methods::OPTION_MAP_OR_NONE_INFO,
crate::methods::OR_FUN_CALL_INFO,
crate::methods::OR_THEN_UNWRAP_INFO,
Expand Down
2 changes: 2 additions & 0 deletions clippy_lints/src/deprecated_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ declare_with_version! { DEPRECATED(DEPRECATED_VERSION): &[(&str, &str)] = &[
("clippy::pub_enum_variant_names", "`clippy::enum_variant_names` now covers this case via the `avoid-breaking-exported-api` config"),
#[clippy::version = "1.54.0"]
("clippy::wrong_pub_self_convention", "`clippy::wrong_self_convention` now covers this case via the `avoid-breaking-exported-api` config"),
#[clippy::version = "1.86.0"]
("clippy::option_map_or_err_ok", "`clippy::manual_ok_or` covers this case"),
// end deprecated lints. used by `cargo dev deprecate_lint`
]}

Expand Down
30 changes: 1 addition & 29 deletions clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ mod ok_expect;
mod open_options;
mod option_as_ref_cloned;
mod option_as_ref_deref;
mod option_map_or_err_ok;
mod option_map_or_none;
mod option_map_unwrap_or;
mod or_fun_call;
Expand Down Expand Up @@ -2640,7 +2639,7 @@ declare_clippy_lint! {
/// ```
#[clippy::version = "1.49.0"]
pub MANUAL_OK_OR,
pedantic,
style,
"finds patterns that can be encoded more concisely with `Option::ok_or`"
}

Expand Down Expand Up @@ -3782,31 +3781,6 @@ declare_clippy_lint! {
"calls to `Path::join` which will overwrite the original path"
}

declare_clippy_lint! {
/// ### What it does
/// Checks for usage of `_.map_or(Err(_), Ok)`.
///
/// ### Why is this bad?
/// Readability, this can be written more concisely as
/// `_.ok_or(_)`.
///
/// ### Example
/// ```no_run
/// # let opt = Some(1);
/// opt.map_or(Err("error"), Ok);
/// ```
///
/// Use instead:
/// ```no_run
/// # let opt = Some(1);
/// opt.ok_or("error");
/// ```
#[clippy::version = "1.76.0"]
pub OPTION_MAP_OR_ERR_OK,
style,
"using `Option.map_or(Err(_), Ok)`, which is more succinctly expressed as `Option.ok_or(_)`"
}

declare_clippy_lint! {
/// ### What it does
/// Checks for iterators of `Result`s using `.filter(Result::is_ok).map(Result::unwrap)` that may
Expand Down Expand Up @@ -4510,7 +4484,6 @@ impl_lint_pass!(Methods => [
WAKER_CLONE_WAKE,
UNNECESSARY_FALLIBLE_CONVERSIONS,
JOIN_ABSOLUTE_PATHS,
OPTION_MAP_OR_ERR_OK,
RESULT_FILTER_MAP,
ITER_FILTER_IS_SOME,
ITER_FILTER_IS_OK,
Expand Down Expand Up @@ -5069,7 +5042,6 @@ impl Methods {
("map_or", [def, map]) => {
option_map_or_none::check(cx, expr, recv, def, map);
manual_ok_or::check(cx, expr, recv, def, map);
option_map_or_err_ok::check(cx, expr, recv, def, map);
unnecessary_map_or::check(cx, expr, recv, def, map, span, &self.msrv);
},
("map_or_else", [def, map]) => {
Expand Down
41 changes: 0 additions & 41 deletions clippy_lints/src/methods/option_map_or_err_ok.rs

This file was deleted.

1 change: 1 addition & 0 deletions tests/ui/deprecated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
#![warn(clippy::regex_macro)] //~ ERROR: lint `clippy::regex_macro`
#![warn(clippy::pub_enum_variant_names)] //~ ERROR: lint `clippy::pub_enum_variant_names`
#![warn(clippy::wrong_pub_self_convention)] //~ ERROR: lint `clippy::wrong_pub_self_convention`
#![warn(clippy::option_map_or_err_ok)] //~ ERROR: lint `clippy::option_map_or_err_ok`

fn main() {}
8 changes: 7 additions & 1 deletion tests/ui/deprecated.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,11 @@ error: lint `clippy::wrong_pub_self_convention` has been removed: `clippy::wrong
LL | #![warn(clippy::wrong_pub_self_convention)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 13 previous errors
error: lint `clippy::option_map_or_err_ok` has been removed: `clippy::manual_ok_or` covers this case
--> tests/ui/deprecated.rs:18:9
|
LL | #![warn(clippy::option_map_or_err_ok)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 14 previous errors

11 changes: 1 addition & 10 deletions tests/ui/manual_ok_or.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ error: this pattern reimplements `Option::ok_or`
LL | foo.map_or(Err("error"), Ok);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `foo.ok_or("error")`

error: called `map_or(Err(_), Ok)` on an `Option` value
--> tests/ui/manual_ok_or.rs:14:5
|
LL | foo.map_or(Err("error"), Ok);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `ok_or`: `foo.ok_or("error")`
|
= note: `-D clippy::option-map-or-err-ok` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::option_map_or_err_ok)]`

error: this pattern reimplements `Option::ok_or`
--> tests/ui/manual_ok_or.rs:17:5
|
Expand All @@ -47,5 +38,5 @@ LL + "{}{}{}{}{}{}{}",
LL ~ "Alice", "Bob", "Sarah", "Marc", "Sandra", "Eric", "Jenifer"));
|

error: aborting due to 5 previous errors
error: aborting due to 4 previous errors

7 changes: 0 additions & 7 deletions tests/ui/option_map_or_err_ok.fixed

This file was deleted.

7 changes: 0 additions & 7 deletions tests/ui/option_map_or_err_ok.rs

This file was deleted.

11 changes: 0 additions & 11 deletions tests/ui/option_map_or_err_ok.stderr

This file was deleted.

Loading