Remove a span from hir::ExprKind::MethodCall

This commit is contained in:
Cameron Steffen
2021-12-01 11:17:50 -06:00
parent ec00cf80a3
commit 82f613ee3b
91 changed files with 162 additions and 168 deletions

View File

@@ -141,7 +141,7 @@ fn expr_eagerness<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> EagernessS
self.eagerness |= NoChange;
return;
},
ExprKind::MethodCall(name, _, args, _) => {
ExprKind::MethodCall(name, args, _) => {
self.eagerness |= self
.cx
.typeck_results()

View File

@@ -258,7 +258,7 @@ impl HirEqInterExpr<'_, '_, '_> {
&& self.eq_expr(l.body, r.body)
})
},
(&ExprKind::MethodCall(l_path, _, l_args, _), &ExprKind::MethodCall(r_path, _, r_args, _)) => {
(&ExprKind::MethodCall(l_path, l_args, _), &ExprKind::MethodCall(r_path, r_args, _)) => {
self.inner.allow_side_effects && self.eq_path_segment(l_path, r_path) && self.eq_exprs(l_args, r_args)
},
(&ExprKind::Repeat(le, ll), &ExprKind::Repeat(re, rl)) => {
@@ -713,7 +713,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
s.hash(&mut self.s);
},
ExprKind::MethodCall(path, ref _tys, args, ref _fn_span) => {
ExprKind::MethodCall(path, args, ref _fn_span) => {
self.hash_name(path.ident.name);
self.hash_exprs(args);
},

View File

@@ -1059,13 +1059,13 @@ pub fn method_calls<'tcx>(
let mut current = expr;
for _ in 0..max_depth {
if let ExprKind::MethodCall(path, span, args, _) = &current.kind {
if let ExprKind::MethodCall(path, args, _) = &current.kind {
if args.iter().any(|e| e.span.from_expansion()) {
break;
}
method_names.push(path.ident.name);
arg_lists.push(&**args);
spans.push(*span);
spans.push(path.ident.span);
current = &args[0];
} else {
break;
@@ -1086,7 +1086,7 @@ pub fn method_chain_args<'a>(expr: &'a Expr<'_>, methods: &[&str]) -> Option<Vec
let mut matched = Vec::with_capacity(methods.len());
for method_name in methods.iter().rev() {
// method chains are stored last -> first
if let ExprKind::MethodCall(path, _, args, _) = current.kind {
if let ExprKind::MethodCall(path, args, _) = current.kind {
if path.ident.name.as_str() == *method_name {
if args.iter().any(|e| e.span.from_expansion()) {
return None;
@@ -1780,7 +1780,7 @@ pub fn is_must_use_func_call(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
None
}
},
ExprKind::MethodCall(_, _, _, _) => cx.typeck_results().type_dependent_def_id(expr.hir_id),
ExprKind::MethodCall(..) => cx.typeck_results().type_dependent_def_id(expr.hir_id),
_ => None,
};

View File

@@ -36,7 +36,7 @@ fn extract_clone_suggestions<'tcx>(
if abort {
return false;
}
if let ExprKind::MethodCall(seg, _, [recv], _) = expr.kind {
if let ExprKind::MethodCall(seg, [recv], _) = expr.kind {
if path_to_local_id(recv, id) {
if seg.ident.name.as_str() == "capacity" {
abort = true;

View File

@@ -863,7 +863,7 @@ impl<'tcx> DerefDelegate<'_, 'tcx> {
/// indicates whether the function from `parent_expr` takes its args by double reference
fn func_takes_arg_by_double_ref(&self, parent_expr: &'tcx hir::Expr<'_>, cmt_hir_id: HirId) -> bool {
let (call_args, inputs) = match parent_expr.kind {
ExprKind::MethodCall(_, _, call_args, _) => {
ExprKind::MethodCall(_, call_args, _) => {
if let Some(method_did) = self.cx.typeck_results().type_dependent_def_id(parent_expr.hir_id) {
(call_args, self.cx.tcx.fn_sig(method_did).skip_binder().inputs())
} else {
@@ -915,7 +915,7 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
match &parent_expr.kind {
// given expression is the self argument and will be handled completely by the compiler
// i.e.: `|x| x.is_something()`
ExprKind::MethodCall(_, _, [self_expr, ..], _) if self_expr.hir_id == cmt.hir_id => {
ExprKind::MethodCall(_, [self_expr, ..], _) if self_expr.hir_id == cmt.hir_id => {
self.suggestion_start
.push_str(&format!("{}{}", start_snip, ident_str_with_proj));
self.next_pos = span.hi();
@@ -923,7 +923,7 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
},
// item is used in a call
// i.e.: `Call`: `|x| please(x)` or `MethodCall`: `|x| [1, 2, 3].contains(x)`
ExprKind::Call(_, [call_args @ ..]) | ExprKind::MethodCall(_, _, [_, call_args @ ..], _) => {
ExprKind::Call(_, [call_args @ ..]) | ExprKind::MethodCall(_, [_, call_args @ ..], _) => {
let expr = self.cx.tcx.hir().expect_expr(cmt.hir_id);
let arg_ty_kind = self.cx.typeck_results().expr_ty(expr).kind();