Auto merge of #12851 - samueltardieu:issue12846, r=y21
Add required parentheses around method receiver Fix #12846 changelog: [`needless_bool`]: Add missing parentheses around method receiver
This commit is contained in:
commit
d553ebef57
6 changed files with 65 additions and 15 deletions
|
|
@ -3401,3 +3401,14 @@ pub fn binary_expr_needs_parentheses(expr: &Expr<'_>) -> bool {
|
|||
|
||||
contains_block(expr, false)
|
||||
}
|
||||
|
||||
/// Returns true if the specified expression is in a receiver position.
|
||||
pub fn is_receiver_of_method_call(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
|
||||
if let Some(parent_expr) = get_parent_expr(cx, expr)
|
||||
&& let ExprKind::MethodCall(_, receiver, ..) = parent_expr.kind
|
||||
&& receiver.hir_id == expr.hir_id
|
||||
{
|
||||
return true;
|
||||
}
|
||||
false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue