Format backport to pass CI
This commit is contained in:
parent
e1225bf9a2
commit
d23a338543
@ -126,7 +126,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
|||||||
target_mut,
|
target_mut,
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
}
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -245,11 +245,14 @@ fn try_parse_contains(cx: &LateContext<'_>, expr: &'tcx Expr<'_>) -> Option<(Map
|
|||||||
ExprKind::MethodCall(
|
ExprKind::MethodCall(
|
||||||
_,
|
_,
|
||||||
_,
|
_,
|
||||||
[map, Expr {
|
[
|
||||||
|
map,
|
||||||
|
Expr {
|
||||||
kind: ExprKind::AddrOf(_, _, key),
|
kind: ExprKind::AddrOf(_, _, key),
|
||||||
span: key_span,
|
span: key_span,
|
||||||
..
|
..
|
||||||
}],
|
},
|
||||||
|
],
|
||||||
_,
|
_,
|
||||||
) if key_span.ctxt() == expr.span.ctxt() => {
|
) if key_span.ctxt() == expr.span.ctxt() => {
|
||||||
let id = cx.typeck_results().type_dependent_def_id(expr.hir_id)?;
|
let id = cx.typeck_results().type_dependent_def_id(expr.hir_id)?;
|
||||||
|
@ -169,13 +169,16 @@ fn check_inputs(cx: &LateContext<'_>, params: &[Param<'_>], call_args: &[Expr<'_
|
|||||||
}
|
}
|
||||||
match *cx.typeck_results().expr_adjustments(arg) {
|
match *cx.typeck_results().expr_adjustments(arg) {
|
||||||
[] => true,
|
[] => true,
|
||||||
[Adjustment {
|
[
|
||||||
|
Adjustment {
|
||||||
kind: Adjust::Deref(None),
|
kind: Adjust::Deref(None),
|
||||||
..
|
..
|
||||||
}, Adjustment {
|
},
|
||||||
|
Adjustment {
|
||||||
kind: Adjust::Borrow(AutoBorrow::Ref(_, mu2)),
|
kind: Adjust::Borrow(AutoBorrow::Ref(_, mu2)),
|
||||||
..
|
..
|
||||||
}] => {
|
},
|
||||||
|
] => {
|
||||||
// re-borrow with the same mutability is allowed
|
// re-borrow with the same mutability is allowed
|
||||||
let ty = cx.typeck_results().expr_ty(arg);
|
let ty = cx.typeck_results().expr_ty(arg);
|
||||||
matches!(*ty.kind(), ty::Ref(.., mu1) if mu1 == mu2.into())
|
matches!(*ty.kind(), ty::Ref(.., mu1) if mu1 == mu2.into())
|
||||||
|
@ -89,7 +89,7 @@ fn check_binop(cx: &EarlyContext<'_>, binop: BinOpKind, lhs: &Expr, rhs: &Expr)
|
|||||||
},
|
},
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
// case where `x + 1 <= ...` or `1 + x <= ...`
|
// case where `x + 1 <= ...` or `1 + x <= ...`
|
||||||
(BinOpKind::Le, &ExprKind::Binary(ref lhskind, ref lhslhs, ref lhsrhs), _)
|
(BinOpKind::Le, &ExprKind::Binary(ref lhskind, ref lhslhs, ref lhsrhs), _)
|
||||||
if lhskind.node == BinOpKind::Add =>
|
if lhskind.node == BinOpKind::Add =>
|
||||||
@ -104,7 +104,7 @@ fn check_binop(cx: &EarlyContext<'_>, binop: BinOpKind, lhs: &Expr, rhs: &Expr)
|
|||||||
},
|
},
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
// case where `... >= y - 1` or `... >= -1 + y`
|
// case where `... >= y - 1` or `... >= -1 + y`
|
||||||
(BinOpKind::Le, _, &ExprKind::Binary(ref rhskind, ref rhslhs, ref rhsrhs)) => {
|
(BinOpKind::Le, _, &ExprKind::Binary(ref rhskind, ref rhslhs, ref rhsrhs)) => {
|
||||||
match (rhskind.node, &rhslhs.kind, &rhsrhs.kind) {
|
match (rhskind.node, &rhslhs.kind, &rhsrhs.kind) {
|
||||||
|
@ -338,7 +338,7 @@ pub(super) fn make_iterator_snippet(cx: &LateContext<'_>, arg: &Expr<'_>, applic
|
|||||||
sugg::Sugg::hir_with_applicability(cx, arg_inner, "_", applic_ref).maybe_par(),
|
sugg::Sugg::hir_with_applicability(cx, arg_inner, "_", applic_ref).maybe_par(),
|
||||||
meth_name,
|
meth_name,
|
||||||
)
|
)
|
||||||
}
|
},
|
||||||
_ => format!(
|
_ => format!(
|
||||||
"{}.into_iter()",
|
"{}.into_iter()",
|
||||||
sugg::Sugg::hir_with_applicability(cx, arg, "_", applic_ref).maybe_par()
|
sugg::Sugg::hir_with_applicability(cx, arg, "_", applic_ref).maybe_par()
|
||||||
|
@ -85,7 +85,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, method_name: Symbol,
|
|||||||
if expr.hir_id == self_arg.hir_id && ty != cx.typeck_results().expr_ty_adjusted(expr) =>
|
if expr.hir_id == self_arg.hir_id && ty != cx.typeck_results().expr_ty_adjusted(expr) =>
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
},
|
||||||
ExprKind::MethodCall(_, _, [self_arg, ..], _) if expr.hir_id == self_arg.hir_id => true,
|
ExprKind::MethodCall(_, _, [self_arg, ..], _) if expr.hir_id == self_arg.hir_id => true,
|
||||||
ExprKind::Match(_, _, MatchSource::TryDesugar | MatchSource::AwaitDesugar)
|
ExprKind::Match(_, _, MatchSource::TryDesugar | MatchSource::AwaitDesugar)
|
||||||
| ExprKind::Field(..)
|
| ExprKind::Field(..)
|
||||||
@ -100,7 +100,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, method_name: Symbol,
|
|||||||
) =>
|
) =>
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
},
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ fn check_general_case<'tcx>(
|
|||||||
check_general_case(cx, name, method_span, &args[0], &args[1], expr.span, None);
|
check_general_case(cx, name, method_span, &args[0], &args[1], expr.span, None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
|
|||||||
}
|
}
|
||||||
process_paths_for_mod_files(path, &mut folder_segments, &mut mod_folders);
|
process_paths_for_mod_files(path, &mut folder_segments, &mut mod_folders);
|
||||||
check_self_named_mod_exists(cx, path, file);
|
check_self_named_mod_exists(cx, path, file);
|
||||||
}
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,14 +107,18 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
|
|||||||
if let ExprKind::AddrOf(BorrowKind::Ref, mutability, inner) = e.kind {
|
if let ExprKind::AddrOf(BorrowKind::Ref, mutability, inner) = e.kind {
|
||||||
if let ty::Ref(_, ty, _) = cx.typeck_results().expr_ty(inner).kind() {
|
if let ty::Ref(_, ty, _) = cx.typeck_results().expr_ty(inner).kind() {
|
||||||
for adj3 in cx.typeck_results().expr_adjustments(e).windows(3) {
|
for adj3 in cx.typeck_results().expr_adjustments(e).windows(3) {
|
||||||
if let [Adjustment {
|
if let [
|
||||||
|
Adjustment {
|
||||||
kind: Adjust::Deref(_), ..
|
kind: Adjust::Deref(_), ..
|
||||||
}, Adjustment {
|
},
|
||||||
|
Adjustment {
|
||||||
kind: Adjust::Deref(_), ..
|
kind: Adjust::Deref(_), ..
|
||||||
}, Adjustment {
|
},
|
||||||
|
Adjustment {
|
||||||
kind: Adjust::Borrow(_),
|
kind: Adjust::Borrow(_),
|
||||||
..
|
..
|
||||||
}] = *adj3
|
},
|
||||||
|
] = *adj3
|
||||||
{
|
{
|
||||||
let help_msg_ty = if matches!(mutability, Mutability::Not) {
|
let help_msg_ty = if matches!(mutability, Mutability::Not) {
|
||||||
format!("&{}", ty)
|
format!("&{}", ty)
|
||||||
|
@ -174,13 +174,13 @@ fn get_vec_init_kind<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Op
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
ExprKind::Path(QPath::Resolved(_, path))
|
ExprKind::Path(QPath::Resolved(_, path))
|
||||||
if match_def_path(cx, path.res.opt_def_id()?, &paths::DEFAULT_TRAIT_METHOD)
|
if match_def_path(cx, path.res.opt_def_id()?, &paths::DEFAULT_TRAIT_METHOD)
|
||||||
&& is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(expr), sym::Vec) =>
|
&& is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(expr), sym::Vec) =>
|
||||||
{
|
{
|
||||||
return Some(VecInitKind::New);
|
return Some(VecInitKind::New);
|
||||||
}
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -846,10 +846,13 @@ fn pat_capture_kind(cx: &LateContext<'_>, pat: &Pat<'_>) -> CaptureKind {
|
|||||||
let mut capture_expr_ty = e;
|
let mut capture_expr_ty = e;
|
||||||
|
|
||||||
for (parent_id, parent) in cx.tcx.hir().parent_iter(e.hir_id) {
|
for (parent_id, parent) in cx.tcx.hir().parent_iter(e.hir_id) {
|
||||||
if let [Adjustment {
|
if let [
|
||||||
|
Adjustment {
|
||||||
kind: Adjust::Deref(_) | Adjust::Borrow(AutoBorrow::Ref(..)),
|
kind: Adjust::Deref(_) | Adjust::Borrow(AutoBorrow::Ref(..)),
|
||||||
target,
|
target,
|
||||||
}, ref adjust @ ..] = *cx
|
},
|
||||||
|
ref adjust @ ..,
|
||||||
|
] = *cx
|
||||||
.typeck_results()
|
.typeck_results()
|
||||||
.adjustments()
|
.adjustments()
|
||||||
.get(child_id)
|
.get(child_id)
|
||||||
@ -1234,9 +1237,7 @@ pub fn get_enclosing_loop_or_closure(tcx: TyCtxt<'tcx>, expr: &Expr<'_>) -> Opti
|
|||||||
for (_, node) in tcx.hir().parent_iter(expr.hir_id) {
|
for (_, node) in tcx.hir().parent_iter(expr.hir_id) {
|
||||||
match node {
|
match node {
|
||||||
Node::Expr(
|
Node::Expr(
|
||||||
e
|
e @ Expr {
|
||||||
@
|
|
||||||
Expr {
|
|
||||||
kind: ExprKind::Loop(..) | ExprKind::Closure(..),
|
kind: ExprKind::Loop(..) | ExprKind::Closure(..),
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
@ -1698,10 +1699,12 @@ pub fn is_async_fn(kind: FnKind<'_>) -> bool {
|
|||||||
pub fn get_async_fn_body(tcx: TyCtxt<'tcx>, body: &Body<'_>) -> Option<&'tcx Expr<'tcx>> {
|
pub fn get_async_fn_body(tcx: TyCtxt<'tcx>, body: &Body<'_>) -> Option<&'tcx Expr<'tcx>> {
|
||||||
if let ExprKind::Call(
|
if let ExprKind::Call(
|
||||||
_,
|
_,
|
||||||
&[Expr {
|
&[
|
||||||
|
Expr {
|
||||||
kind: ExprKind::Closure(_, _, body, _, _),
|
kind: ExprKind::Closure(_, _, body, _, _),
|
||||||
..
|
..
|
||||||
}],
|
},
|
||||||
|
],
|
||||||
) = body.value.kind
|
) = body.value.kind
|
||||||
{
|
{
|
||||||
if let ExprKind::Block(
|
if let ExprKind::Block(
|
||||||
|
Loading…
Reference in New Issue
Block a user