Skip to content

Commit 9174577

Browse files
committed
Use check_source_text for better performance and clarity
1 parent 51b48a1 commit 9174577

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

clippy_lints/src/decimal_bit_mask.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
2+
use clippy_utils::source::SpanRangeExt;
23
use rustc_data_structures::packed::Pu128;
34
use rustc_hir::{AssignOpKind, BinOpKind, Expr, ExprKind};
4-
use rustc_lint::{LateContext, LateLintPass, LintContext};
5+
use rustc_lint::{LateContext, LateLintPass};
56
use rustc_session::declare_lint_pass;
67
use rustc_span::Span;
78
use rustc_span::source_map::Spanned;
@@ -71,11 +72,7 @@ fn check_bitwise_assign_expr(cx: &LateContext<'_>, e: &Expr<'_>) {
7172
}
7273

7374
fn is_not_decimal_number(cx: &LateContext<'_>, span: Span) -> bool {
74-
if let Ok(src) = cx.sess().source_map().span_to_snippet(span) {
75-
src.contains("0b") || src.contains("0x") || src.contains("0o")
76-
} else {
77-
true
78-
}
75+
span.check_source_text(cx, |src| src.contains("0b") || src.contains("0x") || src.contains("0o"))
7976
}
8077

8178
fn is_power_of_twoish(expr: &Expr<'_>) -> bool {

0 commit comments

Comments
 (0)