let len = bindings.len();
for stmt in block.stmts {
match stmt.kind {
- StmtKind::Local(ref local) => check_local(cx, local, bindings),
- StmtKind::Expr(ref e) | StmtKind::Semi(ref e) => check_expr(cx, e, bindings),
+ StmtKind::Local(local) => check_local(cx, local, bindings),
+ StmtKind::Expr(e) | StmtKind::Semi(e) => check_expr(cx, e, bindings),
StmtKind::Item(..) => {},
}
}
- if let Some(ref o) = block.expr {
+ if let Some(o) = block.expr {
check_expr(cx, o, bindings);
}
bindings.truncate(len);
return;
}
let Local {
- ref pat,
+ pat,
ref ty,
ref init,
span,
..
} = *local;
- if let Some(ref t) = *ty {
+ if let Some(t) = *ty {
check_ty(cx, t, bindings)
}
- if let Some(ref o) = *init {
+ if let Some(o) = *init {
check_expr(cx, o, bindings);
check_pat(cx, pat, Some(o), span, bindings);
} else {
bindings.push((name, ident.span));
}
}
- if let Some(ref p) = *inner {
+ if let Some(p) = *inner {
check_pat(cx, p, init, span, bindings);
}
},
PatKind::Struct(_, pfields, _) => {
if let Some(init_struct) = init {
- if let ExprKind::Struct(_, ref efields, _) = init_struct.kind {
+ if let ExprKind::Struct(_, efields, _) = init_struct.kind {
for field in pfields {
let name = field.ident.name;
let efield = efields
.iter()
.find_map(|f| if f.ident.name == name { Some(&*f.expr) } else { None });
- check_pat(cx, &field.pat, efield, span, bindings);
+ check_pat(cx, field.pat, efield, span, bindings);
}
} else {
for field in pfields {
- check_pat(cx, &field.pat, init, span, bindings);
+ check_pat(cx, field.pat, init, span, bindings);
}
}
} else {
for field in pfields {
- check_pat(cx, &field.pat, None, span, bindings);
+ check_pat(cx, field.pat, None, span, bindings);
}
}
},
PatKind::Tuple(inner, _) => {
if let Some(init_tup) = init {
- if let ExprKind::Tup(ref tup) = init_tup.kind {
+ if let ExprKind::Tup(tup) = init_tup.kind {
for (i, p) in inner.iter().enumerate() {
check_pat(cx, p, Some(&tup[i]), p.span, bindings);
}
}
}
},
- PatKind::Box(ref inner) => {
+ PatKind::Box(inner) => {
if let Some(initp) = init {
- if let ExprKind::Box(ref inner_init) = initp.kind {
- check_pat(cx, inner, Some(&**inner_init), span, bindings);
+ if let ExprKind::Box(inner_init) = initp.kind {
+ check_pat(cx, inner, Some(inner_init), span, bindings);
} else {
check_pat(cx, inner, init, span, bindings);
}
check_pat(cx, inner, init, span, bindings);
}
},
- PatKind::Ref(ref inner, _) => check_pat(cx, inner, init, span, bindings),
+ PatKind::Ref(inner, _) => check_pat(cx, inner, init, span, bindings),
// PatVec(Vec<P<Pat>>, Option<P<Pat>>, Vec<P<Pat>>),
_ => (),
}
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::Block(ref block, _) | ExprKind::Loop(ref block, ..) => check_block(cx, block, bindings),
+ ExprKind::Unary(_, e) | ExprKind::Field(e, _) | ExprKind::AddrOf(_, _, e) | ExprKind::Box(e) => {
+ check_expr(cx, e, bindings)
+ },
+ ExprKind::Block(block, _) | ExprKind::Loop(block, ..) => check_block(cx, block, bindings),
// ExprKind::Call
// ExprKind::MethodCall
ExprKind::Array(v) | ExprKind::Tup(v) => {
check_expr(cx, e, bindings)
}
},
- ExprKind::If(ref cond, ref then, ref otherwise) => {
+ ExprKind::If(cond, then, ref otherwise) => {
check_expr(cx, cond, bindings);
- check_expr(cx, &**then, bindings);
- if let Some(ref o) = *otherwise {
+ check_expr(cx, then, bindings);
+ if let Some(o) = *otherwise {
check_expr(cx, o, bindings);
}
},
- ExprKind::Match(ref init, arms, _) => {
+ ExprKind::Match(init, arms, _) => {
check_expr(cx, init, bindings);
let len = bindings.len();
for arm in arms {
- check_pat(cx, &arm.pat, Some(&**init), arm.pat.span, bindings);
+ check_pat(cx, arm.pat, Some(init), arm.pat.span, bindings);
// This is ugly, but needed to get the right type
if let Some(ref guard) = arm.guard {
match guard {
},
}
}
- check_expr(cx, &arm.body, bindings);
+ check_expr(cx, arm.body, bindings);
bindings.truncate(len);
}
},
fn check_ty<'tcx>(cx: &LateContext<'tcx>, ty: &'tcx Ty<'_>, bindings: &mut Vec<(Symbol, Span)>) {
match ty.kind {
- TyKind::Slice(ref sty) => check_ty(cx, sty, bindings),
- TyKind::Array(ref fty, ref anon_const) => {
+ TyKind::Slice(sty) => check_ty(cx, sty, bindings),
+ TyKind::Array(fty, ref anon_const) => {
check_ty(cx, fty, bindings);
check_expr(cx, &cx.tcx.hir().body(anon_const.body).value, bindings);
},
- TyKind::Ptr(MutTy { ty: ref mty, .. }) | TyKind::Rptr(_, MutTy { ty: ref mty, .. }) => {
- check_ty(cx, mty, bindings)
- },
+ TyKind::Ptr(MutTy { ty: mty, .. }) | TyKind::Rptr(_, MutTy { ty: mty, .. }) => check_ty(cx, mty, bindings),
TyKind::Tup(tup) => {
for t in tup {
check_ty(cx, t, bindings)
fn is_self_shadow(name: Symbol, expr: &Expr<'_>) -> bool {
match expr.kind {
- ExprKind::Box(ref inner) | ExprKind::AddrOf(_, _, ref inner) => is_self_shadow(name, inner),
- ExprKind::Block(ref block, _) => {
+ ExprKind::Box(inner) | ExprKind::AddrOf(_, _, inner) => is_self_shadow(name, inner),
+ ExprKind::Block(block, _) => {
block.stmts.is_empty() && block.expr.as_ref().map_or(false, |e| is_self_shadow(name, e))
},
- ExprKind::Unary(op, ref inner) => (UnOp::Deref == op) && is_self_shadow(name, inner),
- ExprKind::Path(QPath::Resolved(_, ref path)) => path_eq_name(name, path),
+ ExprKind::Unary(op, inner) => (UnOp::Deref == op) && is_self_shadow(name, inner),
+ ExprKind::Path(QPath::Resolved(_, path)) => path_eq_name(name, path),
_ => false,
}
}