We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f719599 commit cf3f71dCopy full SHA for cf3f71d
clippy_lints/src/double_parens.rs
@@ -61,9 +61,8 @@ impl EarlyLintPass for DoubleParens {
61
}
62
63
},
64
- ExprKind::MethodCall(_, ref params, _) => {
65
- if params.len() == 2 {
66
- let param = ¶ms[1];
+ ExprKind::MethodCall(_, _, ref params, _) => {
+ if let [ref param] = params[..] {
67
if let ExprKind::Paren(_) = param.kind {
68
span_lint(cx, DOUBLE_PARENS, param.span, msg);
69
clippy_lints/src/option_env_unwrap.rs
@@ -37,9 +37,9 @@ declare_lint_pass!(OptionEnvUnwrap => [OPTION_ENV_UNWRAP]);
37
impl EarlyLintPass for OptionEnvUnwrap {
38
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
39
if_chain! {
40
- if let ExprKind::MethodCall(path_segment, args, _) = &expr.kind;
+ if let ExprKind::MethodCall(path_segment, receiver, _, _) = &expr.kind;
41
if matches!(path_segment.ident.name, sym::expect | sym::unwrap);
42
- if let ExprKind::Call(caller, _) = &args[0].kind;
+ if let ExprKind::Call(caller, _) = &receiver.kind;
43
if is_direct_expn_of(caller.span, "option_env").is_some();
44
then {
45
span_lint_and_help(
clippy_lints/src/precedence.rs
@@ -109,12 +109,12 @@ impl EarlyLintPass for Precedence {
109
let mut arg = operand;
110
111
let mut all_odd = true;
112
- while let ExprKind::MethodCall(path_segment, args, _) = &arg.kind {
+ while let ExprKind::MethodCall(path_segment, receiver, _, _) = &arg.kind {
113
let path_segment_str = path_segment.ident.name.as_str();
114
all_odd &= ALLOWED_ODD_FUNCTIONS
115
.iter()
116
.any(|odd_function| **odd_function == *path_segment_str);
117
- arg = args.first().expect("A method always has a receiver.");
+ arg = receiver;
118
119
120
clippy_lints/src/suspicious_operation_groupings.rs
@@ -595,7 +595,7 @@ fn ident_difference_expr_with_base_location(
595
| (Unary(_, _), Unary(_, _))
596
| (Binary(_, _, _), Binary(_, _, _))
597
| (Tup(_), Tup(_))
598
- | (MethodCall(_, _, _), MethodCall(_, _, _))
+ | (MethodCall(_, _, _, _), MethodCall(_, _, _, _))
599
| (Call(_, _), Call(_, _))
600
| (ConstBlock(_), ConstBlock(_))
601
| (Array(_), Array(_))
clippy_lints/src/unused_rounding.rs
@@ -30,11 +30,10 @@ declare_clippy_lint! {
30
declare_lint_pass!(UnusedRounding => [UNUSED_ROUNDING]);
31
32
fn is_useless_rounding(expr: &Expr) -> Option<(&str, String)> {
33
- if let ExprKind::MethodCall(name_ident, args, _) = &expr.kind
+ if let ExprKind::MethodCall(name_ident, receiver, _, _) = &expr.kind
34
&& let method_name = name_ident.ident.name.as_str()
35
&& (method_name == "ceil" || method_name == "round" || method_name == "floor")
36
- && !args.is_empty()
- && let ExprKind::Lit(spanned) = &args[0].kind
+ && let ExprKind::Lit(spanned) = &receiver.kind
&& let LitKind::Float(symbol, ty) = spanned.kind {
let f = symbol.as_str().parse::<f64>().unwrap();
let f_str = symbol.to_string() + if let LitFloatType::Suffixed(ty) = ty {
clippy_utils/src/ast_utils.rs
@@ -147,7 +147,9 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
147
(Array(l), Array(r)) | (Tup(l), Tup(r)) => over(l, r, |l, r| eq_expr(l, r)),
148
(Repeat(le, ls), Repeat(re, rs)) => eq_expr(le, re) && eq_expr(&ls.value, &rs.value),
149
(Call(lc, la), Call(rc, ra)) => eq_expr(lc, rc) && over(la, ra, |l, r| eq_expr(l, r)),
150
- (MethodCall(lc, la, _), MethodCall(rc, ra, _)) => eq_path_seg(lc, rc) && over(la, ra, |l, r| eq_expr(l, r)),
+ (MethodCall(lc, ls, la, _), MethodCall(rc, rs, ra, _)) => {
151
+ eq_path_seg(lc, rc) && eq_expr(ls, rs) && over(la, ra, |l, r| eq_expr(l, r))
152
+ },
153
(Binary(lo, ll, lr), Binary(ro, rl, rr)) => lo.node == ro.node && eq_expr(ll, rl) && eq_expr(lr, rr),
154
(Unary(lo, l), Unary(ro, r)) => mem::discriminant(lo) == mem::discriminant(ro) && eq_expr(l, r),
155
(Lit(l), Lit(r)) => l.kind == r.kind,
0 commit comments