Skip to content

Commit 3430bc1

Browse files
committed
Re-add wildcards for BorrowKind in some places
1 parent 341e266 commit 3430bc1

File tree

7 files changed

+18
-12
lines changed

7 files changed

+18
-12
lines changed

clippy_lints/src/eval_order_dependence.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReadVisitor<'a, 'tcx> {
328328
// ```
329329
//
330330
// TODO: fix this
331-
ExprKind::AddrOf(BorrowKind::Ref, _, _) => {
331+
ExprKind::AddrOf(_, _, _) => {
332332
return;
333333
}
334334
_ => {}

clippy_lints/src/functions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> {
656656
tys.clear();
657657
}
658658
},
659-
Assign(ref target, _) | AssignOp(_, ref target, _) | AddrOf(BorrowKind::Ref, hir::Mutability::Mutable, ref target) => {
659+
Assign(ref target, _) | AssignOp(_, ref target, _) | AddrOf(_, hir::Mutability::Mutable, ref target) => {
660660
self.mutates_static |= is_mutated_static(self.cx, target)
661661
},
662662
_ => {},

clippy_lints/src/no_effect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn has_no_effect(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
5858
| ExprKind::Type(ref inner, _)
5959
| ExprKind::Unary(_, ref inner)
6060
| ExprKind::Field(ref inner, _)
61-
| ExprKind::AddrOf(BorrowKind::Ref, _, ref inner)
61+
| ExprKind::AddrOf(_, _, ref inner)
6262
| ExprKind::Box(ref inner) => has_no_effect(cx, inner),
6363
ExprKind::Struct(_, ref fields, ref base) => {
6464
!has_drop(cx, cx.tables.expr_ty(expr))
@@ -134,7 +134,7 @@ fn reduce_expression<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) -> Option<Vec
134134
| ExprKind::Type(ref inner, _)
135135
| ExprKind::Unary(_, ref inner)
136136
| ExprKind::Field(ref inner, _)
137-
| ExprKind::AddrOf(BorrowKind::Ref, _, ref inner)
137+
| ExprKind::AddrOf(_, _, ref inner)
138138
| ExprKind::Box(ref inner) => reduce_expression(cx, inner).or_else(|| Some(vec![inner])),
139139
ExprKind::Struct(_, ref fields, ref base) => {
140140
if has_drop(cx, cx.tables.expr_ty(expr)) {

clippy_lints/src/reference.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl EarlyLintPass for DerefAddrOf {
3737
fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &Expr) {
3838
if_chain! {
3939
if let ExprKind::Unary(UnOp::Deref, ref deref_target) = e.kind;
40-
if let ExprKind::AddrOf(BorrowKind::Ref, _, ref addrof_target) = without_parens(deref_target).kind;
40+
if let ExprKind::AddrOf(_, _, ref addrof_target) = without_parens(deref_target).kind;
4141
if !in_macro(addrof_target.span);
4242
then {
4343
let mut applicability = Applicability::MachineApplicable;
@@ -80,7 +80,7 @@ impl EarlyLintPass for RefInDeref {
8080
if_chain! {
8181
if let ExprKind::Field(ref object, _) = e.kind;
8282
if let ExprKind::Paren(ref parened) = object.kind;
83-
if let ExprKind::AddrOf(BorrowKind::Ref, _, ref inner) = parened.kind;
83+
if let ExprKind::AddrOf(_, _, ref inner) = parened.kind;
8484
then {
8585
let mut applicability = Applicability::MachineApplicable;
8686
span_lint_and_sugg(

clippy_lints/src/shadow.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ fn check_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, bindings:
315315
match expr.kind {
316316
ExprKind::Unary(_, ref e)
317317
| ExprKind::Field(ref e, _)
318-
| ExprKind::AddrOf(BorrowKind::Ref, _, ref e)
318+
| ExprKind::AddrOf(_, _, ref e)
319319
| ExprKind::Box(ref e) => check_expr(cx, e, bindings),
320320
ExprKind::Block(ref block, _) | ExprKind::Loop(ref block, _, _) => check_block(cx, block, bindings),
321321
// ExprKind::Call
@@ -366,7 +366,7 @@ fn check_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: &'tcx Ty, bindings: &mut V
366366

367367
fn is_self_shadow(name: Name, expr: &Expr) -> bool {
368368
match expr.kind {
369-
ExprKind::Box(ref inner) | ExprKind::AddrOf(BorrowKind::Ref, _, ref inner) => is_self_shadow(name, inner),
369+
ExprKind::Box(ref inner) | ExprKind::AddrOf(_, _, ref inner) => is_self_shadow(name, inner),
370370
ExprKind::Block(ref block, _) => {
371371
block.stmts.is_empty() && block.expr.as_ref().map_or(false, |e| is_self_shadow(name, e))
372372
},

clippy_lints/src/utils/hir_utils.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> {
7878
}
7979

8080
match (&left.kind, &right.kind) {
81-
(&ExprKind::AddrOf(BorrowKind::Ref, l_mut, ref le), &ExprKind::AddrOf(BorrowKind::Ref, r_mut, ref re)) => {
82-
l_mut == r_mut && self.eq_expr(le, re)
81+
(&ExprKind::AddrOf(lb, l_mut, ref le), &ExprKind::AddrOf(rb, r_mut, ref re)) => {
82+
lb == rb && l_mut == r_mut && self.eq_expr(le, re)
8383
},
8484
(&ExprKind::Continue(li), &ExprKind::Continue(ri)) => {
8585
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> {
398398
std::mem::discriminant(&e.kind).hash(&mut self.s);
399399

400400
match e.kind {
401-
ExprKind::AddrOf(BorrowKind::Ref, m, ref e) => {
401+
ExprKind::AddrOf(kind, m, ref e) => {
402+
match kind {
403+
BorrowKind::Ref => 0,
404+
BorrowKind::Raw => 1,
405+
}
406+
.hash(&mut self.s);
402407
m.hash(&mut self.s);
403408
self.hash_expr(e);
404409
},

clippy_lints/src/utils/inspector.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,9 @@ fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr, indent: usize) {
264264
println!("{}Relative Path, {:?}", ind, ty);
265265
println!("{}seg: {:?}", ind, seg);
266266
},
267-
hir::ExprKind::AddrOf(BorrowKind::Ref, ref muta, ref e) => {
267+
hir::ExprKind::AddrOf(kind, ref muta, ref e) => {
268268
println!("{}AddrOf", ind);
269+
println!("kind: {:?}", kind);
269270
println!("mutability: {:?}", muta);
270271
print_expr(cx, e, indent + 1);
271272
},

0 commit comments

Comments
 (0)