Re-add wildcards for BorrowKind in some places
This commit is contained in:
parent
341e266508
commit
3430bc1bc5
@ -328,7 +328,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReadVisitor<'a, 'tcx> {
|
||||
// ```
|
||||
//
|
||||
// TODO: fix this
|
||||
ExprKind::AddrOf(BorrowKind::Ref, _, _) => {
|
||||
ExprKind::AddrOf(_, _, _) => {
|
||||
return;
|
||||
}
|
||||
_ => {}
|
||||
|
@ -656,7 +656,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> {
|
||||
tys.clear();
|
||||
}
|
||||
},
|
||||
Assign(ref target, _) | AssignOp(_, ref target, _) | AddrOf(BorrowKind::Ref, hir::Mutability::Mutable, ref target) => {
|
||||
Assign(ref target, _) | AssignOp(_, ref target, _) | AddrOf(_, hir::Mutability::Mutable, ref target) => {
|
||||
self.mutates_static |= is_mutated_static(self.cx, target)
|
||||
},
|
||||
_ => {},
|
||||
|
@ -58,7 +58,7 @@ fn has_no_effect(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
|
||||
| ExprKind::Type(ref inner, _)
|
||||
| ExprKind::Unary(_, ref inner)
|
||||
| ExprKind::Field(ref inner, _)
|
||||
| ExprKind::AddrOf(BorrowKind::Ref, _, ref inner)
|
||||
| ExprKind::AddrOf(_, _, ref inner)
|
||||
| ExprKind::Box(ref inner) => has_no_effect(cx, inner),
|
||||
ExprKind::Struct(_, ref fields, ref base) => {
|
||||
!has_drop(cx, cx.tables.expr_ty(expr))
|
||||
@ -134,7 +134,7 @@ fn reduce_expression<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) -> Option<Vec
|
||||
| ExprKind::Type(ref inner, _)
|
||||
| ExprKind::Unary(_, ref inner)
|
||||
| ExprKind::Field(ref inner, _)
|
||||
| ExprKind::AddrOf(BorrowKind::Ref, _, ref inner)
|
||||
| ExprKind::AddrOf(_, _, ref inner)
|
||||
| ExprKind::Box(ref inner) => reduce_expression(cx, inner).or_else(|| Some(vec![inner])),
|
||||
ExprKind::Struct(_, ref fields, ref base) => {
|
||||
if has_drop(cx, cx.tables.expr_ty(expr)) {
|
||||
|
@ -37,7 +37,7 @@ impl EarlyLintPass for DerefAddrOf {
|
||||
fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &Expr) {
|
||||
if_chain! {
|
||||
if let ExprKind::Unary(UnOp::Deref, ref deref_target) = e.kind;
|
||||
if let ExprKind::AddrOf(BorrowKind::Ref, _, ref addrof_target) = without_parens(deref_target).kind;
|
||||
if let ExprKind::AddrOf(_, _, ref addrof_target) = without_parens(deref_target).kind;
|
||||
if !in_macro(addrof_target.span);
|
||||
then {
|
||||
let mut applicability = Applicability::MachineApplicable;
|
||||
@ -80,7 +80,7 @@ impl EarlyLintPass for RefInDeref {
|
||||
if_chain! {
|
||||
if let ExprKind::Field(ref object, _) = e.kind;
|
||||
if let ExprKind::Paren(ref parened) = object.kind;
|
||||
if let ExprKind::AddrOf(BorrowKind::Ref, _, ref inner) = parened.kind;
|
||||
if let ExprKind::AddrOf(_, _, ref inner) = parened.kind;
|
||||
then {
|
||||
let mut applicability = Applicability::MachineApplicable;
|
||||
span_lint_and_sugg(
|
||||
|
@ -315,7 +315,7 @@ fn check_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, bindings:
|
||||
match expr.kind {
|
||||
ExprKind::Unary(_, ref e)
|
||||
| ExprKind::Field(ref e, _)
|
||||
| ExprKind::AddrOf(BorrowKind::Ref, _, 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
|
||||
@ -366,7 +366,7 @@ fn check_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: &'tcx Ty, bindings: &mut V
|
||||
|
||||
fn is_self_shadow(name: Name, expr: &Expr) -> bool {
|
||||
match expr.kind {
|
||||
ExprKind::Box(ref inner) | ExprKind::AddrOf(BorrowKind::Ref, _, ref inner) => is_self_shadow(name, inner),
|
||||
ExprKind::Box(ref inner) | ExprKind::AddrOf(_, _, ref inner) => is_self_shadow(name, inner),
|
||||
ExprKind::Block(ref block, _) => {
|
||||
block.stmts.is_empty() && block.expr.as_ref().map_or(false, |e| is_self_shadow(name, e))
|
||||
},
|
||||
|
@ -78,8 +78,8 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> {
|
||||
}
|
||||
|
||||
match (&left.kind, &right.kind) {
|
||||
(&ExprKind::AddrOf(BorrowKind::Ref, l_mut, ref le), &ExprKind::AddrOf(BorrowKind::Ref, r_mut, ref re)) => {
|
||||
l_mut == r_mut && self.eq_expr(le, re)
|
||||
(&ExprKind::AddrOf(lb, l_mut, ref le), &ExprKind::AddrOf(rb, r_mut, ref re)) => {
|
||||
lb == rb && l_mut == r_mut && self.eq_expr(le, re)
|
||||
},
|
||||
(&ExprKind::Continue(li), &ExprKind::Continue(ri)) => {
|
||||
both(&li.label, &ri.label, |l, r| l.ident.as_str() == r.ident.as_str())
|
||||
@ -398,7 +398,12 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
|
||||
std::mem::discriminant(&e.kind).hash(&mut self.s);
|
||||
|
||||
match e.kind {
|
||||
ExprKind::AddrOf(BorrowKind::Ref, m, ref e) => {
|
||||
ExprKind::AddrOf(kind, m, ref e) => {
|
||||
match kind {
|
||||
BorrowKind::Ref => 0,
|
||||
BorrowKind::Raw => 1,
|
||||
}
|
||||
.hash(&mut self.s);
|
||||
m.hash(&mut self.s);
|
||||
self.hash_expr(e);
|
||||
},
|
||||
|
@ -264,8 +264,9 @@ fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr, indent: usize) {
|
||||
println!("{}Relative Path, {:?}", ind, ty);
|
||||
println!("{}seg: {:?}", ind, seg);
|
||||
},
|
||||
hir::ExprKind::AddrOf(BorrowKind::Ref, ref muta, ref e) => {
|
||||
hir::ExprKind::AddrOf(kind, ref muta, ref e) => {
|
||||
println!("{}AddrOf", ind);
|
||||
println!("kind: {:?}", kind);
|
||||
println!("mutability: {:?}", muta);
|
||||
print_expr(cx, e, indent + 1);
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user