about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2021-09-10 18:48:25 -0700
committerMichael Howell <michael@notriddle.com>2021-09-10 18:48:25 -0700
commitd98892b67f9b1f04c8c3c90cd99cd24738fd30ba (patch)
treea8a08594322b9c5c1e95dbf0c12ef01c9d81871c
parente5c2412e52019ef35f9c6b3524cd5caf972e26b7 (diff)
downloadrust-d98892b67f9b1f04c8c3c90cd99cd24738fd30ba.tar.gz
rust-d98892b67f9b1f04c8c3c90cd99cd24738fd30ba.zip
Make sure the call span parens check only fires on the callee, not args
-rw-r--r--compiler/rustc_typeck/src/check/expr.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/compiler/rustc_typeck/src/check/expr.rs b/compiler/rustc_typeck/src/check/expr.rs
index 85136593440..61d5b6985f1 100644
--- a/compiler/rustc_typeck/src/check/expr.rs
+++ b/compiler/rustc_typeck/src/check/expr.rs
@@ -1842,13 +1842,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             expr_t
         );
         err.span_label(field.span, "method, not a field");
-        let expr_is_call = if let hir::Node::Expr(parent_expr) =
-            self.tcx.hir().get(self.tcx.hir().get_parent_node(expr.hir_id))
-        {
-            matches!(parent_expr.kind, ExprKind::Call(..))
-        } else {
-            false
-        };
+        let expr_is_call =
+            if let hir::Node::Expr(hir::Expr { kind: ExprKind::Call(callee, _args), .. }) =
+                self.tcx.hir().get(self.tcx.hir().get_parent_node(expr.hir_id))
+            {
+                expr.hir_id == callee.hir_id
+            } else {
+                false
+            };
         let expr_snippet =
             self.tcx.sess.source_map().span_to_snippet(expr.span).unwrap_or(String::new());
         if expr_is_call && expr_snippet.starts_with("(") && expr_snippet.ends_with(")") {