Skip to content

Commit

Permalink
Use int assoc consts in checked_conversions lint
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Apr 7, 2020
1 parent b192f2c commit 4726daa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions clippy_lints/src/checked_conversions.rs
Expand Up @@ -21,7 +21,7 @@ declare_clippy_lint! {
/// ```rust
/// # let foo: u32 = 5;
/// # let _ =
/// foo <= i32::max_value() as u32
/// foo <= i32::MAX as u32
/// # ;
/// ```
///
Expand Down Expand Up @@ -179,7 +179,7 @@ impl ConversionType {
}
}

/// Check for `expr <= (to_type::max_value() as from_type)`
/// Check for `expr <= (to_type::MAX as from_type)`
fn check_upper_bound<'tcx>(expr: &'tcx Expr<'tcx>) -> Option<Conversion<'tcx>> {
if_chain! {
if let ExprKind::Binary(ref op, ref left, ref right) = &expr.kind;
Expand All @@ -194,7 +194,7 @@ fn check_upper_bound<'tcx>(expr: &'tcx Expr<'tcx>) -> Option<Conversion<'tcx>> {
}
}

/// Check for `expr >= 0|(to_type::min_value() as from_type)`
/// Check for `expr >= 0|(to_type::MIN as from_type)`
fn check_lower_bound<'tcx>(expr: &'tcx Expr<'tcx>) -> Option<Conversion<'tcx>> {
fn check_function<'a>(candidate: &'a Expr<'a>, check: &'a Expr<'a>) -> Option<Conversion<'a>> {
(check_lower_bound_zero(candidate, check)).or_else(|| (check_lower_bound_min(candidate, check)))
Expand Down Expand Up @@ -222,7 +222,7 @@ fn check_lower_bound_zero<'a>(candidate: &'a Expr<'_>, check: &'a Expr<'_>) -> O
}
}

/// Check for `expr >= (to_type::min_value() as from_type)`
/// Check for `expr >= (to_type::MIN as from_type)`
fn check_lower_bound_min<'a>(candidate: &'a Expr<'_>, check: &'a Expr<'_>) -> Option<Conversion<'a>> {
if let Some((from, to)) = get_types_from_cast(check, MIN_VALUE, SINTS) {
Conversion::try_new(candidate, from, to)
Expand Down

0 comments on commit 4726daa

Please sign in to comment.