about summary refs log tree commit diff
path: root/clippy_lints
diff options
context:
space:
mode:
authorDeadbeef <ent3rm4n@gmail.com>2023-07-27 17:56:25 +0000
committerDeadbeef <ent3rm4n@gmail.com>2023-07-27 17:56:25 +0000
commit39fb315396a70bf08ea6f030d1e97c4ef91128da (patch)
treec655d0969c21d264abbdf5515fd85ac62eea8381 /clippy_lints
parentbe0b4d5a9bd6943220026345dd72a3013d434dce (diff)
downloadrust-39fb315396a70bf08ea6f030d1e97c4ef91128da.tar.gz
rust-39fb315396a70bf08ea6f030d1e97c4ef91128da.zip
bless clippy
Diffstat (limited to 'clippy_lints')
-rw-r--r--clippy_lints/src/manual_float_methods.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/clippy_lints/src/manual_float_methods.rs b/clippy_lints/src/manual_float_methods.rs
index ccd2f06aad2..f48a5d9d245 100644
--- a/clippy_lints/src/manual_float_methods.rs
+++ b/clippy_lints/src/manual_float_methods.rs
@@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint_and_then;
 use clippy_utils::source::snippet_opt;
 use clippy_utils::{is_from_proc_macro, path_to_local};
 use rustc_errors::Applicability;
-use rustc_hir::{BinOpKind, Expr, ExprKind};
+use rustc_hir::{BinOpKind, Constness, Expr, ExprKind};
 use rustc_lint::{LateContext, LateLintPass, Lint, LintContext};
 use rustc_middle::lint::in_external_macro;
 use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -83,8 +83,10 @@ impl Variant {
 impl<'tcx> LateLintPass<'tcx> for ManualFloatMethods {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
         if !in_external_macro(cx.sess(), expr.span)
-            && cx.tcx.features().active(sym!(const_float_classify))
-            && let ExprKind::Binary(kind, lhs, rhs) = expr.kind
+            && (
+                matches!(cx.tcx.constness(cx.tcx.hir().enclosing_body_owner(expr.hir_id)), Constness::NotConst) 
+                    || cx.tcx.features().active(sym!(const_float_classify))
+            ) && let ExprKind::Binary(kind, lhs, rhs) = expr.kind
             && let ExprKind::Binary(lhs_kind, lhs_lhs, lhs_rhs) = lhs.kind
             && let ExprKind::Binary(rhs_kind, rhs_lhs, rhs_rhs) = rhs.kind
             // Checking all possible scenarios using a function would be a hopeless task, as we have