Skip to content

Commit c94f0f4

Browse files
committed
Remove all ref keyword
1 parent 75ad839 commit c94f0f4

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

clippy_lints/src/loops.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -772,8 +772,8 @@ fn check_for_loop<'a, 'tcx>(
772772

773773
fn same_var<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &Expr<'_>, var: HirId) -> bool {
774774
if_chain! {
775-
if let ExprKind::Path(ref qpath) = expr.kind;
776-
if let QPath::Resolved(None, ref path) = *qpath;
775+
if let ExprKind::Path(qpath) = &expr.kind;
776+
if let QPath::Resolved(None, path) = qpath;
777777
if path.segments.len() == 1;
778778
if let Res::Local(local_id) = qpath_res(cx, qpath, expr.hir_id);
779779
// our variable!
@@ -821,8 +821,8 @@ fn is_slice_like<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'_>) -> bool {
821821

822822
fn get_fixed_offset_var<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &Expr<'_>, var: HirId) -> Option<FixedOffsetVar> {
823823
fn extract_offset<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, e: &Expr<'_>, var: HirId) -> Option<String> {
824-
match e.kind {
825-
ExprKind::Lit(ref l) => match l.node {
824+
match &e.kind {
825+
ExprKind::Lit(l) => match l.node {
826826
ast::LitKind::Int(x, _ty) => Some(x.to_string()),
827827
_ => None,
828828
},
@@ -831,14 +831,14 @@ fn get_fixed_offset_var<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &Expr<'_>, v
831831
}
832832
}
833833

834-
if let ExprKind::Index(ref seqexpr, ref idx) = expr.kind {
834+
if let ExprKind::Index(seqexpr, idx) = expr.kind {
835835
let ty = cx.tables.expr_ty(seqexpr);
836836
if !is_slice_like(cx, ty) {
837837
return None;
838838
}
839839

840840
let offset = match idx.kind {
841-
ExprKind::Binary(op, ref lhs, ref rhs) => match op.node {
841+
ExprKind::Binary(op, lhs, rhs) => match op.node {
842842
BinOpKind::Add => {
843843
let offset_opt = if same_var(cx, lhs, var) {
844844
extract_offset(cx, rhs, var)
@@ -878,7 +878,7 @@ fn fetch_cloned_fixed_offset_var<'a, 'tcx>(
878878
var: HirId,
879879
) -> Option<FixedOffsetVar> {
880880
if_chain! {
881-
if let ExprKind::MethodCall(ref method, _, ref args) = expr.kind;
881+
if let ExprKind::MethodCall(method, _, args) = expr.kind;
882882
if method.ident.name == sym!(clone);
883883
if args.len() == 1;
884884
if let Some(arg) = args.get(0);
@@ -900,7 +900,7 @@ fn get_indexed_assignments<'a, 'tcx>(
900900
e: &Expr<'_>,
901901
var: HirId,
902902
) -> Option<(FixedOffsetVar, FixedOffsetVar)> {
903-
if let ExprKind::Assign(ref lhs, ref rhs, _) = e.kind {
903+
if let ExprKind::Assign(lhs, rhs, _) = e.kind {
904904
match (
905905
get_fixed_offset_var(cx, lhs, var),
906906
fetch_cloned_fixed_offset_var(cx, rhs, var),
@@ -920,16 +920,14 @@ fn get_indexed_assignments<'a, 'tcx>(
920920
}
921921
}
922922

923-
if let ExprKind::Block(ref b, _) = body.kind {
924-
let Block {
925-
ref stmts, ref expr, ..
926-
} = **b;
923+
if let ExprKind::Block(b, _) = body.kind {
924+
let Block { stmts, expr, .. } = *b;
927925

928926
stmts
929927
.iter()
930928
.map(|stmt| match stmt.kind {
931929
StmtKind::Local(..) | StmtKind::Item(..) => None,
932-
StmtKind::Expr(ref e) | StmtKind::Semi(ref e) => Some(get_assignment(cx, e, var)),
930+
StmtKind::Expr(e) | StmtKind::Semi(e) => Some(get_assignment(cx, e, var)),
933931
})
934932
.chain(expr.as_ref().into_iter().map(|e| Some(get_assignment(cx, &*e, var))))
935933
.filter_map(|op| op)
@@ -992,7 +990,7 @@ fn detect_manual_memcpy<'a, 'tcx>(
992990

993991
let print_limit = |end: &Expr<'_>, offset: Offset, var_name: &str| {
994992
if_chain! {
995-
if let ExprKind::MethodCall(ref method, _, ref len_args) = end.kind;
993+
if let ExprKind::MethodCall(method, _, len_args) = end.kind;
996994
if method.ident.name == sym!(len);
997995
if len_args.len() == 1;
998996
if let Some(arg) = len_args.get(0);

0 commit comments

Comments
 (0)