/// let x: Result<u32, &str> = Ok(10);
/// x.expect_err("Testing expect_err");
/// ```
- #[clippy::version = "1.61.0"]
+ #[clippy::version = "1.62.0"]
pub ERR_EXPECT,
style,
r#"using `.err().expect("")` when `.expect_err("")` can be used"#
declare_clippy_lint! {
/// ### What it does
- /// Finds usages of [`char::is_digit`]
- /// (https://doc.rust-lang.org/stable/std/primitive.char.html#method.is_digit) that
- /// can be replaced with [`is_ascii_digit`]
- /// (https://doc.rust-lang.org/stable/std/primitive.char.html#method.is_ascii_digit) or
- /// [`is_ascii_hexdigit`]
- /// (https://doc.rust-lang.org/stable/std/primitive.char.html#method.is_ascii_hexdigit).
+ /// Finds usages of [`char::is_digit`](https://doc.rust-lang.org/stable/std/primitive.char.html#method.is_digit) that
+ /// can be replaced with [`is_ascii_digit`](https://doc.rust-lang.org/stable/std/primitive.char.html#method.is_ascii_digit) or
+ /// [`is_ascii_hexdigit`](https://doc.rust-lang.org/stable/std/primitive.char.html#method.is_ascii_hexdigit).
///
/// ### Why is this bad?
/// `is_digit(..)` is slower and requires specifying the radix.
/// c.is_ascii_digit();
/// c.is_ascii_hexdigit();
/// ```
- #[clippy::version = "1.61.0"]
+ #[clippy::version = "1.62.0"]
pub IS_DIGIT_ASCII_RADIX,
style,
"use of `char::is_digit(..)` with literal radix of 10 or 16"
}
declare_clippy_lint! {
+ /// ### What it does
+ /// Checks for calling `take` function after `as_ref`.
///
/// ### Why is this bad?
+ /// Redundant code. `take` writes `None` to its argument.
+ /// In this case the modification is useless as it's a temporary that cannot be read from afterwards.
///
/// ### Example
/// ```rust
/// let x = Some(3);
/// x.as_ref();
/// ```
- #[clippy::version = "1.61.0"]
+ #[clippy::version = "1.62.0"]
pub NEEDLESS_OPTION_TAKE,
complexity,
"using `.as_ref().take()` on a temporary value"
}
},
("take", []) => needless_option_take::check(cx, expr, recv),
+ ("then", [arg]) => {
+ if !meets_msrv(self.msrv, msrvs::BOOL_THEN_SOME) {
+ return;
+ }
+ unnecessary_lazy_eval::check(cx, expr, recv, arg, "then_some");
+ },
("to_os_string" | "to_owned" | "to_path_buf" | "to_vec", []) => {
implicit_clone::check(cx, name, expr, recv);
},