Skip to content

Commit e509232

Browse files
committed
Replace eval with is_const_evaluatable to reduce overhead during linting
1 parent 21f02ba commit e509232

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

clippy_lints/src/methods/chunks_exact_with_const_size.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
use super::CHUNKS_EXACT_WITH_CONST_SIZE;
2-
use clippy_utils::consts::{ConstEvalCtxt, Constant};
32
use clippy_utils::diagnostics::span_lint_and_then;
43
use clippy_utils::msrvs::{self, Msrv};
54
use clippy_utils::source::snippet_with_applicability;
65
use clippy_utils::sym;
6+
use clippy_utils::visitors::is_const_evaluatable;
77
use rustc_errors::Applicability;
88
use rustc_hir::{Expr, Node, PatKind};
99
use rustc_lint::LateContext;
1010
use rustc_middle::ty;
1111
use rustc_span::{Span, Symbol};
1212

13-
pub(super) fn check(
14-
cx: &LateContext<'_>,
15-
recv: &Expr<'_>,
16-
arg: &Expr<'_>,
17-
expr: &Expr<'_>,
13+
pub(super) fn check<'tcx>(
14+
cx: &LateContext<'tcx>,
15+
recv: &'tcx Expr<'tcx>,
16+
arg: &'tcx Expr<'tcx>,
17+
expr: &'tcx Expr<'tcx>,
1818
call_span: Span,
1919
method_name: Symbol,
2020
msrv: Msrv,
@@ -24,8 +24,7 @@ pub(super) fn check(
2424
return;
2525
}
2626

27-
let constant_eval = ConstEvalCtxt::new(cx);
28-
if let Some(Constant::Int(_)) = constant_eval.eval(arg) {
27+
if is_const_evaluatable(cx, arg) {
2928
if !msrv.meets(cx, msrvs::AS_CHUNKS) {
3029
return;
3130
}

0 commit comments

Comments
 (0)