Fix clippy uses of QPath::LangItem

This commit is contained in:
Esteban Kuber 2021-11-16 20:44:25 +00:00
parent 41c48bd390
commit d8af82e4bb
8 changed files with 13 additions and 13 deletions

View file

@ -204,7 +204,7 @@ fn parse_iter_usage(
match e.kind { match e.kind {
ExprKind::Call( ExprKind::Call(
Expr { Expr {
kind: ExprKind::Path(QPath::LangItem(LangItem::TryTraitBranch, _)), kind: ExprKind::Path(QPath::LangItem(LangItem::TryTraitBranch, ..)),
.. ..
}, },
_, _,

View file

@ -105,7 +105,7 @@ fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
}; };
if let ExprKind::Match(inner_expr_with_q, _, MatchSource::TryDesugar) = &arg.kind; if let ExprKind::Match(inner_expr_with_q, _, MatchSource::TryDesugar) = &arg.kind;
if let ExprKind::Call(called, [inner_expr]) = &inner_expr_with_q.kind; if let ExprKind::Call(called, [inner_expr]) = &inner_expr_with_q.kind;
if let ExprKind::Path(QPath::LangItem(LangItem::TryTraitBranch, _)) = &called.kind; if let ExprKind::Path(QPath::LangItem(LangItem::TryTraitBranch, ..)) = &called.kind;
if expr.span.ctxt() == inner_expr.span.ctxt(); if expr.span.ctxt() == inner_expr.span.ctxt();
let expr_ty = cx.typeck_results().expr_ty(expr); let expr_ty = cx.typeck_results().expr_ty(expr);
let inner_ty = cx.typeck_results().expr_ty(inner_expr); let inner_ty = cx.typeck_results().expr_ty(inner_expr);

View file

@ -260,7 +260,7 @@ impl<'tcx> LateLintPass<'tcx> for StringLitAsBytes {
if method_names[0] == sym!(as_bytes); if method_names[0] == sym!(as_bytes);
// Check for slicer // Check for slicer
if let ExprKind::Struct(QPath::LangItem(LangItem::Range, _), _, _) = right.kind; if let ExprKind::Struct(QPath::LangItem(LangItem::Range, ..), _, _) = right.kind;
then { then {
let mut applicability = Applicability::MachineApplicable; let mut applicability = Applicability::MachineApplicable;

View file

@ -65,7 +65,7 @@ impl<'tcx> LateLintPass<'tcx> for TryErr {
if let ExprKind::Match(match_arg, _, MatchSource::TryDesugar) = expr.kind; if let ExprKind::Match(match_arg, _, MatchSource::TryDesugar) = expr.kind;
if let ExprKind::Call(match_fun, try_args) = match_arg.kind; if let ExprKind::Call(match_fun, try_args) = match_arg.kind;
if let ExprKind::Path(ref match_fun_path) = match_fun.kind; if let ExprKind::Path(ref match_fun_path) = match_fun.kind;
if matches!(match_fun_path, QPath::LangItem(LangItem::TryTraitBranch, _)); if matches!(match_fun_path, QPath::LangItem(LangItem::TryTraitBranch, ..));
if let Some(try_arg) = try_args.get(0); if let Some(try_arg) = try_args.get(0);
if let ExprKind::Call(err_fun, err_args) = try_arg.kind; if let ExprKind::Call(err_fun, err_args) = try_arg.kind;
if let Some(err_arg) = err_args.get(0); if let Some(err_arg) = err_args.get(0);

View file

@ -49,7 +49,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedIoAmount {
if let hir::ExprKind::Call(func, [ref arg_0, ..]) = res.kind { if let hir::ExprKind::Call(func, [ref arg_0, ..]) = res.kind {
if matches!( if matches!(
func.kind, func.kind,
hir::ExprKind::Path(hir::QPath::LangItem(hir::LangItem::TryTraitBranch, _)) hir::ExprKind::Path(hir::QPath::LangItem(hir::LangItem::TryTraitBranch, ..))
) { ) {
check_map_error(cx, arg_0, expr); check_map_error(cx, arg_0, expr);
} }

View file

@ -260,7 +260,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
} }
fn qpath(&self, qpath: &Binding<&QPath<'_>>) { fn qpath(&self, qpath: &Binding<&QPath<'_>>) {
if let QPath::LangItem(lang_item, _) = *qpath.value { if let QPath::LangItem(lang_item, ..) = *qpath.value {
out!("if matches!({qpath}, QPath::LangItem(LangItem::{lang_item:?}, _));"); out!("if matches!({qpath}, QPath::LangItem(LangItem::{lang_item:?}, _));");
} else { } else {
out!("if match_qpath({qpath}, &[{}]);", path_to_string(qpath.value)); out!("if match_qpath({qpath}, &[{}]);", path_to_string(qpath.value));

View file

@ -218,7 +218,7 @@ impl<'a> Range<'a> {
hir::ExprKind::Call(path, args) hir::ExprKind::Call(path, args)
if matches!( if matches!(
path.kind, path.kind,
hir::ExprKind::Path(hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, _)) hir::ExprKind::Path(hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, ..))
) => ) =>
{ {
Some(Range { Some(Range {
@ -228,27 +228,27 @@ impl<'a> Range<'a> {
}) })
}, },
hir::ExprKind::Struct(path, fields, None) => match &path { hir::ExprKind::Struct(path, fields, None) => match &path {
hir::QPath::LangItem(hir::LangItem::RangeFull, _) => Some(Range { hir::QPath::LangItem(hir::LangItem::RangeFull, ..) => Some(Range {
start: None, start: None,
end: None, end: None,
limits: ast::RangeLimits::HalfOpen, limits: ast::RangeLimits::HalfOpen,
}), }),
hir::QPath::LangItem(hir::LangItem::RangeFrom, _) => Some(Range { hir::QPath::LangItem(hir::LangItem::RangeFrom, ..) => Some(Range {
start: Some(get_field("start", fields)?), start: Some(get_field("start", fields)?),
end: None, end: None,
limits: ast::RangeLimits::HalfOpen, limits: ast::RangeLimits::HalfOpen,
}), }),
hir::QPath::LangItem(hir::LangItem::Range, _) => Some(Range { hir::QPath::LangItem(hir::LangItem::Range, ..) => Some(Range {
start: Some(get_field("start", fields)?), start: Some(get_field("start", fields)?),
end: Some(get_field("end", fields)?), end: Some(get_field("end", fields)?),
limits: ast::RangeLimits::HalfOpen, limits: ast::RangeLimits::HalfOpen,
}), }),
hir::QPath::LangItem(hir::LangItem::RangeToInclusive, _) => Some(Range { hir::QPath::LangItem(hir::LangItem::RangeToInclusive, ..) => Some(Range {
start: None, start: None,
end: Some(get_field("end", fields)?), end: Some(get_field("end", fields)?),
limits: ast::RangeLimits::Closed, limits: ast::RangeLimits::Closed,
}), }),
hir::QPath::LangItem(hir::LangItem::RangeTo, _) => Some(Range { hir::QPath::LangItem(hir::LangItem::RangeTo, ..) => Some(Range {
start: None, start: None,
end: Some(get_field("end", fields)?), end: Some(get_field("end", fields)?),
limits: ast::RangeLimits::HalfOpen, limits: ast::RangeLimits::HalfOpen,

View file

@ -346,7 +346,7 @@ impl HirEqInterExpr<'_, '_, '_> {
(&QPath::TypeRelative(lty, lseg), &QPath::TypeRelative(rty, rseg)) => { (&QPath::TypeRelative(lty, lseg), &QPath::TypeRelative(rty, rseg)) => {
self.eq_ty(lty, rty) && self.eq_path_segment(lseg, rseg) self.eq_ty(lty, rty) && self.eq_path_segment(lseg, rseg)
}, },
(&QPath::LangItem(llang_item, _), &QPath::LangItem(rlang_item, _)) => llang_item == rlang_item, (&QPath::LangItem(llang_item, ..), &QPath::LangItem(rlang_item, ..)) => llang_item == rlang_item,
_ => false, _ => false,
} }
} }