use rustc_session::{declare_tool_lint, impl_lint_pass};
declare_clippy_lint! {
- /// **What it does:** Checks for explicit bounds checking when casting.
+ /// ### What it does
+ /// Checks for explicit bounds checking when casting.
///
- /// **Why is this bad?** Reduces the readability of statements & is error prone.
+ /// ### Why is this bad?
+ /// Reduces the readability of statements & is error prone.
///
- /// **Known problems:** None.
- ///
- /// **Example:**
+ /// ### Example
/// ```rust
/// # let foo: u32 = 5;
/// # let _ =
/// i32::try_from(foo).is_ok()
/// # ;
/// ```
+ #[clippy::version = "1.37.0"]
pub CHECKED_CONVERSIONS,
pedantic,
"`try_from` could replace manual bounds checking when casting"
if let TyKind::Path(QPath::Resolved(None, tp)) = &ty.kind;
if let [int] = &*tp.segments;
then {
- let name = &int.ident.name.as_str();
- candidates.iter().find(|c| name == *c).copied()
+ let name = int.ident.name.as_str();
+ candidates.iter().find(|c| &name == *c).copied()
} else {
None
}
if let QPath::Resolved(_, path) = *path;
if let [ty] = &*path.segments;
then {
- let name = &ty.ident.name.as_str();
- INTS.iter().find(|c| name == *c).copied()
+ let name = ty.ident.name.as_str();
+ INTS.iter().find(|c| &name == *c).copied()
} else {
None
}