about summary refs log tree commit diff
path: root/clippy_lints/src/declared_lints.rs
diff options
context:
space:
mode:
authordswij <dharmasw@outlook.com>2025-02-07 17:34:21 +0000
committerGitHub <noreply@github.com>2025-02-07 17:34:21 +0000
commit4e5d00a0a729e7783701ea93edefde1aa3908b59 (patch)
treed12549976182c84ce1e4da032f2d944e47eaeccf /clippy_lints/src/declared_lints.rs
parent0d3bf65bd45435c91a776972b7da8500562c2fe1 (diff)
parenta03242f8e0e7ac1d15b2e78568dcbb5e92e9f258 (diff)
downloadrust-4e5d00a0a729e7783701ea93edefde1aa3908b59.tar.gz
rust-4e5d00a0a729e7783701ea93edefde1aa3908b59.zip
Deprecate redundant lint `option_map_or_err_ok` and take `manual_ok_or` out of pedantic (#14027)
While extending the `option_map_or_err_ok` lint (warn by default,
"style") to recognize η-expanded forms of `Ok`, as in

```rust
    // Should suggest `opt.ok_or("foobar")`
   let _ = opt.map_or(Err("foobar"), |x| Ok(x));
```

I discovered that the `manual_ok_or` lint (allow by default, "pedantic")
already covered exactly the cases handled by `option_map_or_err_ok`,
including the one I was adding. Apparently, `option_map_or_err_ok` was
added without realizing that the lint already existed under the
`manual_ok_or` name. As a matter of fact, artifacts of this second lint
were even present in the first lint `stderr` file and went unnoticed for
more than a year.

This PR:
- deprecates `option_map_or_err_ok` with a message saying to use
`manual_ok_or`
- moves `manual_ok_or` from "pedantic" to "style" (the category in which
`option_map_or_err_ok` was)

In addition, I think that this lint, which is short, machine applicable,
and leads to shorter and clearer code with less arguments (`Ok`
disappears) and the removal of one level of call (`Err(x)` is replaced
by `x`), is a reason by itself to be in "style".

changelog: [`option_map_or_err_ok` and `manual_ok_or`]: move
`manual_ok_or` from "pedantic" to "style", and deprecate the redundant
style lint `option_map_or_err_ok`.
Diffstat (limited to 'clippy_lints/src/declared_lints.rs')
-rw-r--r--clippy_lints/src/declared_lints.rs1
1 files changed, 0 insertions, 1 deletions
diff --git a/clippy_lints/src/declared_lints.rs b/clippy_lints/src/declared_lints.rs
index 9fbeab5bf2e..1f4a5c29ea9 100644
--- a/clippy_lints/src/declared_lints.rs
+++ b/clippy_lints/src/declared_lints.rs
@@ -452,7 +452,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,