Skip to content

Commit add515f

Browse files
committed
Fix sync fallout
1 parent d2672f7 commit add515f

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

clippy_lints/src/dereference.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Dereferencing {
7373
fn lint_deref(cx: &LateContext<'_, '_>, method_name: &str, call_expr: &Expr<'_>, var_span: Span, expr_span: Span) {
7474
match method_name {
7575
"deref" => {
76-
if cx.tcx.lang_items().deref_trait().map_or(false, |id| {
76+
let impls_deref_trait = cx.tcx.lang_items().deref_trait().map_or(false, |id| {
7777
implements_trait(cx, cx.tables().expr_ty(&call_expr), id, &[])
78-
}) {
78+
});
79+
if impls_deref_trait {
7980
span_lint_and_sugg(
8081
cx,
8182
EXPLICIT_DEREF_METHODS,
@@ -88,9 +89,10 @@ fn lint_deref(cx: &LateContext<'_, '_>, method_name: &str, call_expr: &Expr<'_>,
8889
}
8990
},
9091
"deref_mut" => {
91-
if cx.tcx.lang_items().deref_mut_trait().map_or(false, |id| {
92+
let impls_deref_mut_trait = cx.tcx.lang_items().deref_mut_trait().map_or(false, |id| {
9293
implements_trait(cx, cx.tables().expr_ty(&call_expr), id, &[])
93-
}) {
94+
});
95+
if impls_deref_mut_trait {
9496
span_lint_and_sugg(
9597
cx,
9698
EXPLICIT_DEREF_METHODS,

clippy_lints/src/utils/sugg.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -325,22 +325,22 @@ pub fn make_unop(op: &str, expr: Sugg<'_>) -> Sugg<'static> {
325325
/// parenthesis will always be added for a mix of these.
326326
pub fn make_assoc(op: AssocOp, lhs: &Sugg<'_>, rhs: &Sugg<'_>) -> Sugg<'static> {
327327
/// Returns `true` if the operator is a shift operator `<<` or `>>`.
328-
fn is_shift(op: &AssocOp) -> bool {
329-
matches!(*op, AssocOp::ShiftLeft | AssocOp::ShiftRight)
328+
fn is_shift(op: AssocOp) -> bool {
329+
matches!(op, AssocOp::ShiftLeft | AssocOp::ShiftRight)
330330
}
331331

332332
/// Returns `true` if the operator is a arithmetic operator
333333
/// (i.e., `+`, `-`, `*`, `/`, `%`).
334-
fn is_arith(op: &AssocOp) -> bool {
334+
fn is_arith(op: AssocOp) -> bool {
335335
matches!(
336-
*op,
336+
op,
337337
AssocOp::Add | AssocOp::Subtract | AssocOp::Multiply | AssocOp::Divide | AssocOp::Modulus
338338
)
339339
}
340340

341341
/// Returns `true` if the operator `op` needs parenthesis with the operator
342342
/// `other` in the direction `dir`.
343-
fn needs_paren(op: &AssocOp, other: &AssocOp, dir: Associativity) -> bool {
343+
fn needs_paren(op: AssocOp, other: AssocOp, dir: Associativity) -> bool {
344344
other.precedence() < op.precedence()
345345
|| (other.precedence() == op.precedence()
346346
&& ((op != other && associativity(op) != dir)
@@ -349,14 +349,14 @@ pub fn make_assoc(op: AssocOp, lhs: &Sugg<'_>, rhs: &Sugg<'_>) -> Sugg<'static>
349349
|| is_shift(other) && is_arith(op)
350350
}
351351

352-
let lhs_paren = if let Sugg::BinOp(ref lop, _) = *lhs {
353-
needs_paren(&op, lop, Associativity::Left)
352+
let lhs_paren = if let Sugg::BinOp(lop, _) = *lhs {
353+
needs_paren(op, lop, Associativity::Left)
354354
} else {
355355
false
356356
};
357357

358-
let rhs_paren = if let Sugg::BinOp(ref rop, _) = *rhs {
359-
needs_paren(&op, rop, Associativity::Right)
358+
let rhs_paren = if let Sugg::BinOp(rop, _) = *rhs {
359+
needs_paren(op, rop, Associativity::Right)
360360
} else {
361361
false
362362
};
@@ -424,13 +424,13 @@ enum Associativity {
424424
/// they are considered
425425
/// associative.
426426
#[must_use]
427-
fn associativity(op: &AssocOp) -> Associativity {
427+
fn associativity(op: AssocOp) -> Associativity {
428428
use rustc_ast::util::parser::AssocOp::{
429429
Add, As, Assign, AssignOp, BitAnd, BitOr, BitXor, Colon, Divide, DotDot, DotDotEq, Equal, Greater,
430430
GreaterEqual, LAnd, LOr, Less, LessEqual, Modulus, Multiply, NotEqual, ShiftLeft, ShiftRight, Subtract,
431431
};
432432

433-
match *op {
433+
match op {
434434
Assign | AssignOp(_) => Associativity::Right,
435435
Add | BitAnd | BitOr | BitXor | LAnd | LOr | Multiply | As | Colon => Associativity::Both,
436436
Divide | Equal | Greater | GreaterEqual | Less | LessEqual | Modulus | NotEqual | ShiftLeft | ShiftRight

tests/ui-cargo/multiple_crate_versions/fail/src/main.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: multiple versions for dependency `winapi`: 0.2.8, 0.3.8
1+
error: multiple versions for dependency `winapi`: 0.2.8, 0.3.9
22
|
33
= note: `-D clippy::multiple-crate-versions` implied by `-D warnings`
44

0 commit comments

Comments
 (0)