mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 07:00:55 +00:00
Run rustfmt
This commit is contained in:
parent
d2d62de841
commit
6eeac46b91
4 changed files with 18 additions and 8 deletions
|
@ -101,7 +101,9 @@ fn check_arg(name: Name, arg: Name, needle: &Expr) -> bool {
|
|||
|
||||
fn get_path_name(expr: &Expr) -> Option<Name> {
|
||||
match expr.kind {
|
||||
ExprKind::Box(ref e) | ExprKind::AddrOf(_, _, ref e) | ExprKind::Unary(UnOp::UnDeref, ref e) => get_path_name(e),
|
||||
ExprKind::Box(ref e) | ExprKind::AddrOf(_, _, ref e) | ExprKind::Unary(UnOp::UnDeref, ref e) => {
|
||||
get_path_name(e)
|
||||
},
|
||||
ExprKind::Block(ref b, _) => {
|
||||
if b.stmts.is_empty() {
|
||||
b.expr.as_ref().and_then(|p| get_path_name(p))
|
||||
|
|
|
@ -1504,7 +1504,9 @@ fn make_iterator_snippet(cx: &LateContext<'_, '_>, arg: &Expr, applic_ref: &mut
|
|||
// (&x).into_iter() ==> x.iter()
|
||||
// (&mut x).into_iter() ==> x.iter_mut()
|
||||
match &arg.kind {
|
||||
ExprKind::AddrOf(_, mutability, arg_inner) if has_iter_method(cx, cx.tables.expr_ty(&arg_inner)).is_some() => {
|
||||
ExprKind::AddrOf(_, mutability, arg_inner)
|
||||
if has_iter_method(cx, cx.tables.expr_ty(&arg_inner)).is_some() =>
|
||||
{
|
||||
let meth_name = match mutability {
|
||||
Mutability::Mutable => "iter_mut",
|
||||
Mutability::Immutable => "iter",
|
||||
|
@ -1514,7 +1516,7 @@ fn make_iterator_snippet(cx: &LateContext<'_, '_>, arg: &Expr, applic_ref: &mut
|
|||
sugg::Sugg::hir_with_applicability(cx, &arg_inner, "_", applic_ref).maybe_par(),
|
||||
meth_name,
|
||||
)
|
||||
},
|
||||
}
|
||||
_ => format!(
|
||||
"{}.into_iter()",
|
||||
sugg::Sugg::hir_with_applicability(cx, arg, "_", applic_ref).maybe_par()
|
||||
|
@ -2090,7 +2092,9 @@ impl<'a, 'tcx> Visitor<'tcx> for IncrementVisitor<'a, 'tcx> {
|
|||
}
|
||||
},
|
||||
ExprKind::Assign(ref lhs, _) if lhs.hir_id == expr.hir_id => *state = VarState::DontWarn,
|
||||
ExprKind::AddrOf(_, mutability, _) if mutability == Mutability::Mutable => *state = VarState::DontWarn,
|
||||
ExprKind::AddrOf(_, mutability, _) if mutability == Mutability::Mutable => {
|
||||
*state = VarState::DontWarn
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -313,9 +313,10 @@ fn check_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, bindings:
|
|||
return;
|
||||
}
|
||||
match expr.kind {
|
||||
ExprKind::Unary(_, ref e) | ExprKind::Field(ref e, _) | ExprKind::AddrOf(_, _, ref e) | ExprKind::Box(ref e) => {
|
||||
check_expr(cx, e, bindings)
|
||||
},
|
||||
ExprKind::Unary(_, ref e)
|
||||
| ExprKind::Field(ref e, _)
|
||||
| ExprKind::AddrOf(_, _, ref e)
|
||||
| ExprKind::Box(ref e) => check_expr(cx, e, bindings),
|
||||
ExprKind::Block(ref block, _) | ExprKind::Loop(ref block, _, _) => check_block(cx, block, bindings),
|
||||
// ExprKind::Call
|
||||
// ExprKind::MethodCall
|
||||
|
|
|
@ -427,7 +427,10 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
|
|||
},
|
||||
ExprKind::AddrOf(_, mutability, ref inner) => {
|
||||
let inner_pat = self.next("inner");
|
||||
println!("AddrOf(_, Mutability::{:?}, ref {}) = {};", mutability, inner_pat, current);
|
||||
println!(
|
||||
"AddrOf(_, Mutability::{:?}, ref {}) = {};",
|
||||
mutability, inner_pat, current
|
||||
);
|
||||
self.current = inner_pat;
|
||||
self.visit_expr(inner);
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue