We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 341e266 commit 3430bc1Copy full SHA for 3430bc1
clippy_lints/src/eval_order_dependence.rs
@@ -328,7 +328,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReadVisitor<'a, 'tcx> {
328
// ```
329
//
330
// TODO: fix this
331
- ExprKind::AddrOf(BorrowKind::Ref, _, _) => {
+ ExprKind::AddrOf(_, _, _) => {
332
return;
333
}
334
_ => {}
clippy_lints/src/functions.rs
@@ -656,7 +656,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> {
656
tys.clear();
657
658
},
659
- 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) => {
660
self.mutates_static |= is_mutated_static(self.cx, target)
661
662
_ => {},
clippy_lints/src/no_effect.rs
@@ -58,7 +58,7 @@ fn has_no_effect(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
58
| ExprKind::Type(ref inner, _)
59
| ExprKind::Unary(_, ref inner)
60
| ExprKind::Field(ref inner, _)
61
- | ExprKind::AddrOf(BorrowKind::Ref, _, ref inner)
+ | ExprKind::AddrOf(_, _, ref inner)
62
| ExprKind::Box(ref inner) => has_no_effect(cx, inner),
63
ExprKind::Struct(_, ref fields, ref base) => {
64
!has_drop(cx, cx.tables.expr_ty(expr))
@@ -134,7 +134,7 @@ fn reduce_expression<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) -> Option<Vec
134
135
136
137
138
| ExprKind::Box(ref inner) => reduce_expression(cx, inner).or_else(|| Some(vec![inner])),
139
140
if has_drop(cx, cx.tables.expr_ty(expr)) {
clippy_lints/src/reference.rs
@@ -37,7 +37,7 @@ impl EarlyLintPass for DerefAddrOf {
37
fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &Expr) {
38
if_chain! {
39
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;
+ if let ExprKind::AddrOf(_, _, ref addrof_target) = without_parens(deref_target).kind;
41
if !in_macro(addrof_target.span);
42
then {
43
let mut applicability = Applicability::MachineApplicable;
@@ -80,7 +80,7 @@ impl EarlyLintPass for RefInDeref {
80
81
if let ExprKind::Field(ref object, _) = e.kind;
82
if let ExprKind::Paren(ref parened) = object.kind;
83
- if let ExprKind::AddrOf(BorrowKind::Ref, _, ref inner) = parened.kind;
+ if let ExprKind::AddrOf(_, _, ref inner) = parened.kind;
84
85
86
span_lint_and_sugg(
clippy_lints/src/shadow.rs
@@ -315,7 +315,7 @@ fn check_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, bindings:
315
match expr.kind {
316
ExprKind::Unary(_, ref e)
317
| ExprKind::Field(ref e, _)
318
- | ExprKind::AddrOf(BorrowKind::Ref, _, ref e)
+ | ExprKind::AddrOf(_, _, ref e)
319
| ExprKind::Box(ref e) => check_expr(cx, e, bindings),
320
ExprKind::Block(ref block, _) | ExprKind::Loop(ref block, _, _) => check_block(cx, block, bindings),
321
// ExprKind::Call
@@ -366,7 +366,7 @@ fn check_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: &'tcx Ty, bindings: &mut V
366
367
fn is_self_shadow(name: Name, expr: &Expr) -> bool {
368
369
- 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),
370
ExprKind::Block(ref block, _) => {
371
block.stmts.is_empty() && block.expr.as_ref().map_or(false, |e| is_self_shadow(name, e))
372
clippy_lints/src/utils/hir_utils.rs
@@ -78,8 +78,8 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> {
78
79
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> {
398
std::mem::discriminant(&e.kind).hash(&mut self.s);
399
400
match e.kind {
401
- ExprKind::AddrOf(BorrowKind::Ref, m, ref e) => {
+ ExprKind::AddrOf(kind, m, ref e) => {
402
+ match kind {
403
+ BorrowKind::Ref => 0,
404
+ BorrowKind::Raw => 1,
405
+ }
406
+ .hash(&mut self.s);
407
m.hash(&mut self.s);
408
self.hash_expr(e);
409
clippy_lints/src/utils/inspector.rs
@@ -264,8 +264,9 @@ fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr, indent: usize) {
264
println!("{}Relative Path, {:?}", ind, ty);
265
println!("{}seg: {:?}", ind, seg);
266
267
- hir::ExprKind::AddrOf(BorrowKind::Ref, ref muta, ref e) => {
+ hir::ExprKind::AddrOf(kind, ref muta, ref e) => {
268
println!("{}AddrOf", ind);
269
+ println!("kind: {:?}", kind);
270
println!("mutability: {:?}", muta);
271
print_expr(cx, e, indent + 1);
272
0 commit comments