Skip to content

Commit 70f100f

Browse files
committed
Use is_range_literal to simplifiy code
1 parent ea24a25 commit 70f100f

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

clippy_lints/src/methods/slice_as_bytes.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
use clippy_utils::{diagnostics::span_lint_and_sugg, source::snippet_with_applicability, ty::is_type_lang_item};
22
use rustc_errors::Applicability;
3-
use rustc_hir::{
4-
Expr, ExprKind,
5-
LangItem::{self, Range, RangeFrom, RangeFull, RangeTo, RangeToInclusive},
6-
QPath,
7-
};
3+
use rustc_hir::{is_range_literal, Expr, ExprKind, LangItem};
84
use rustc_lint::LateContext;
95

106
use super::SLICE_AS_BYTES;
117

128
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>) {
139
if let ExprKind::Index(indexed, index) = recv.kind {
14-
if let ExprKind::Struct(QPath::LangItem(Range | RangeFrom | RangeTo | RangeToInclusive | RangeFull, ..), ..) =
15-
index.kind
16-
{
10+
if is_range_literal(index) {
1711
let ty = cx.typeck_results().expr_ty(indexed).peel_refs();
1812
let is_str = ty.is_str();
1913
let is_string = is_type_lang_item(cx, ty, LangItem::String);

0 commit comments

Comments
 (0)