Do not consider method call receiver as an argument in AST.
This commit is contained in:
parent
f719599c0f
commit
cf3f71d2a2
6 changed files with 12 additions and 12 deletions
|
|
@ -61,9 +61,8 @@ impl EarlyLintPass for DoubleParens {
|
|||
}
|
||||
}
|
||||
},
|
||||
ExprKind::MethodCall(_, ref params, _) => {
|
||||
if params.len() == 2 {
|
||||
let param = ¶ms[1];
|
||||
ExprKind::MethodCall(_, _, ref params, _) => {
|
||||
if let [ref param] = params[..] {
|
||||
if let ExprKind::Paren(_) = param.kind {
|
||||
span_lint(cx, DOUBLE_PARENS, param.span, msg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ declare_lint_pass!(OptionEnvUnwrap => [OPTION_ENV_UNWRAP]);
|
|||
impl EarlyLintPass for OptionEnvUnwrap {
|
||||
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
|
||||
if_chain! {
|
||||
if let ExprKind::MethodCall(path_segment, args, _) = &expr.kind;
|
||||
if let ExprKind::MethodCall(path_segment, receiver, _, _) = &expr.kind;
|
||||
if matches!(path_segment.ident.name, sym::expect | sym::unwrap);
|
||||
if let ExprKind::Call(caller, _) = &args[0].kind;
|
||||
if let ExprKind::Call(caller, _) = &receiver.kind;
|
||||
if is_direct_expn_of(caller.span, "option_env").is_some();
|
||||
then {
|
||||
span_lint_and_help(
|
||||
|
|
|
|||
|
|
@ -109,12 +109,12 @@ impl EarlyLintPass for Precedence {
|
|||
let mut arg = operand;
|
||||
|
||||
let mut all_odd = true;
|
||||
while let ExprKind::MethodCall(path_segment, args, _) = &arg.kind {
|
||||
while let ExprKind::MethodCall(path_segment, receiver, _, _) = &arg.kind {
|
||||
let path_segment_str = path_segment.ident.name.as_str();
|
||||
all_odd &= ALLOWED_ODD_FUNCTIONS
|
||||
.iter()
|
||||
.any(|odd_function| **odd_function == *path_segment_str);
|
||||
arg = args.first().expect("A method always has a receiver.");
|
||||
arg = receiver;
|
||||
}
|
||||
|
||||
if_chain! {
|
||||
|
|
|
|||
|
|
@ -595,7 +595,7 @@ fn ident_difference_expr_with_base_location(
|
|||
| (Unary(_, _), Unary(_, _))
|
||||
| (Binary(_, _, _), Binary(_, _, _))
|
||||
| (Tup(_), Tup(_))
|
||||
| (MethodCall(_, _, _), MethodCall(_, _, _))
|
||||
| (MethodCall(_, _, _, _), MethodCall(_, _, _, _))
|
||||
| (Call(_, _), Call(_, _))
|
||||
| (ConstBlock(_), ConstBlock(_))
|
||||
| (Array(_), Array(_))
|
||||
|
|
|
|||
|
|
@ -30,11 +30,10 @@ declare_clippy_lint! {
|
|||
declare_lint_pass!(UnusedRounding => [UNUSED_ROUNDING]);
|
||||
|
||||
fn is_useless_rounding(expr: &Expr) -> Option<(&str, String)> {
|
||||
if let ExprKind::MethodCall(name_ident, args, _) = &expr.kind
|
||||
if let ExprKind::MethodCall(name_ident, receiver, _, _) = &expr.kind
|
||||
&& let method_name = name_ident.ident.name.as_str()
|
||||
&& (method_name == "ceil" || method_name == "round" || method_name == "floor")
|
||||
&& !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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue