Skip to content

Commit 06221e6

Browse files
committed
Deprecate the option_map_or_err_ok lint
1 parent 2c8d1ae commit 06221e6

10 files changed

+11
-106
lines changed

clippy_lints/src/declared_lints.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,6 @@ pub static LINTS: &[&crate::LintInfo] = &[
449449
crate::methods::OPTION_AS_REF_CLONED_INFO,
450450
crate::methods::OPTION_AS_REF_DEREF_INFO,
451451
crate::methods::OPTION_FILTER_MAP_INFO,
452-
crate::methods::OPTION_MAP_OR_ERR_OK_INFO,
453452
crate::methods::OPTION_MAP_OR_NONE_INFO,
454453
crate::methods::OR_FUN_CALL_INFO,
455454
crate::methods::OR_THEN_UNWRAP_INFO,

clippy_lints/src/deprecated_lints.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ declare_with_version! { DEPRECATED(DEPRECATED_VERSION): &[(&str, &str)] = &[
4040
("clippy::pub_enum_variant_names", "`clippy::enum_variant_names` now covers this case via the `avoid-breaking-exported-api` config"),
4141
#[clippy::version = "1.54.0"]
4242
("clippy::wrong_pub_self_convention", "`clippy::wrong_self_convention` now covers this case via the `avoid-breaking-exported-api` config"),
43+
#[clippy::version = "1.86.0"]
44+
("clippy::option_map_or_err_ok", "`clippy::manual_ok_or` covers this case"),
4345
// end deprecated lints. used by `cargo dev deprecate_lint`
4446
]}
4547

clippy_lints/src/methods/mod.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ mod ok_expect;
8282
mod open_options;
8383
mod option_as_ref_cloned;
8484
mod option_as_ref_deref;
85-
mod option_map_or_err_ok;
8685
mod option_map_or_none;
8786
mod option_map_unwrap_or;
8887
mod or_fun_call;
@@ -3782,31 +3781,6 @@ declare_clippy_lint! {
37823781
"calls to `Path::join` which will overwrite the original path"
37833782
}
37843783

3785-
declare_clippy_lint! {
3786-
/// ### What it does
3787-
/// Checks for usage of `_.map_or(Err(_), Ok)`.
3788-
///
3789-
/// ### Why is this bad?
3790-
/// Readability, this can be written more concisely as
3791-
/// `_.ok_or(_)`.
3792-
///
3793-
/// ### Example
3794-
/// ```no_run
3795-
/// # let opt = Some(1);
3796-
/// opt.map_or(Err("error"), Ok);
3797-
/// ```
3798-
///
3799-
/// Use instead:
3800-
/// ```no_run
3801-
/// # let opt = Some(1);
3802-
/// opt.ok_or("error");
3803-
/// ```
3804-
#[clippy::version = "1.76.0"]
3805-
pub OPTION_MAP_OR_ERR_OK,
3806-
style,
3807-
"using `Option.map_or(Err(_), Ok)`, which is more succinctly expressed as `Option.ok_or(_)`"
3808-
}
3809-
38103784
declare_clippy_lint! {
38113785
/// ### What it does
38123786
/// Checks for iterators of `Result`s using `.filter(Result::is_ok).map(Result::unwrap)` that may
@@ -4510,7 +4484,6 @@ impl_lint_pass!(Methods => [
45104484
WAKER_CLONE_WAKE,
45114485
UNNECESSARY_FALLIBLE_CONVERSIONS,
45124486
JOIN_ABSOLUTE_PATHS,
4513-
OPTION_MAP_OR_ERR_OK,
45144487
RESULT_FILTER_MAP,
45154488
ITER_FILTER_IS_SOME,
45164489
ITER_FILTER_IS_OK,
@@ -5069,7 +5042,6 @@ impl Methods {
50695042
("map_or", [def, map]) => {
50705043
option_map_or_none::check(cx, expr, recv, def, map);
50715044
manual_ok_or::check(cx, expr, recv, def, map);
5072-
option_map_or_err_ok::check(cx, expr, recv, def, map);
50735045
unnecessary_map_or::check(cx, expr, recv, def, map, span, &self.msrv);
50745046
},
50755047
("map_or_else", [def, map]) => {

clippy_lints/src/methods/option_map_or_err_ok.rs

Lines changed: 0 additions & 41 deletions
This file was deleted.

tests/ui/deprecated.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
#![warn(clippy::regex_macro)] //~ ERROR: lint `clippy::regex_macro`
1616
#![warn(clippy::pub_enum_variant_names)] //~ ERROR: lint `clippy::pub_enum_variant_names`
1717
#![warn(clippy::wrong_pub_self_convention)] //~ ERROR: lint `clippy::wrong_pub_self_convention`
18+
#![warn(clippy::option_map_or_err_ok)] //~ ERROR: lint `clippy::option_map_or_err_ok`
1819

1920
fn main() {}

tests/ui/deprecated.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,11 @@ error: lint `clippy::wrong_pub_self_convention` has been removed: `clippy::wrong
7979
LL | #![warn(clippy::wrong_pub_self_convention)]
8080
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8181

82-
error: aborting due to 13 previous errors
82+
error: lint `clippy::option_map_or_err_ok` has been removed: `clippy::manual_ok_or` covers this case
83+
--> tests/ui/deprecated.rs:18:9
84+
|
85+
LL | #![warn(clippy::option_map_or_err_ok)]
86+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
87+
88+
error: aborting due to 14 previous errors
8389

tests/ui/manual_ok_or.stderr

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@ error: this pattern reimplements `Option::ok_or`
1313
LL | foo.map_or(Err("error"), Ok);
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `foo.ok_or("error")`
1515

16-
error: called `map_or(Err(_), Ok)` on an `Option` value
17-
--> tests/ui/manual_ok_or.rs:14:5
18-
|
19-
LL | foo.map_or(Err("error"), Ok);
20-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `ok_or`: `foo.ok_or("error")`
21-
|
22-
= note: `-D clippy::option-map-or-err-ok` implied by `-D warnings`
23-
= help: to override `-D warnings` add `#[allow(clippy::option_map_or_err_ok)]`
24-
2516
error: this pattern reimplements `Option::ok_or`
2617
--> tests/ui/manual_ok_or.rs:17:5
2718
|
@@ -47,5 +38,5 @@ LL + "{}{}{}{}{}{}{}",
4738
LL ~ "Alice", "Bob", "Sarah", "Marc", "Sandra", "Eric", "Jenifer"));
4839
|
4940

50-
error: aborting due to 5 previous errors
41+
error: aborting due to 4 previous errors
5142

tests/ui/option_map_or_err_ok.fixed

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/ui/option_map_or_err_ok.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/ui/option_map_or_err_ok.stderr

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)