Skip to content

Commit d98892b

Browse files
committed
Make sure the call span parens check only fires on the callee, not args
1 parent e5c2412 commit d98892b

File tree

1 file changed

+8
-7
lines changed
  • compiler/rustc_typeck/src/check

1 file changed

+8
-7
lines changed

compiler/rustc_typeck/src/check/expr.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -1842,13 +1842,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18421842
expr_t
18431843
);
18441844
err.span_label(field.span, "method, not a field");
1845-
let expr_is_call = if let hir::Node::Expr(parent_expr) =
1846-
self.tcx.hir().get(self.tcx.hir().get_parent_node(expr.hir_id))
1847-
{
1848-
matches!(parent_expr.kind, ExprKind::Call(..))
1849-
} else {
1850-
false
1851-
};
1845+
let expr_is_call =
1846+
if let hir::Node::Expr(hir::Expr { kind: ExprKind::Call(callee, _args), .. }) =
1847+
self.tcx.hir().get(self.tcx.hir().get_parent_node(expr.hir_id))
1848+
{
1849+
expr.hir_id == callee.hir_id
1850+
} else {
1851+
false
1852+
};
18521853
let expr_snippet =
18531854
self.tcx.sess.source_map().span_to_snippet(expr.span).unwrap_or(String::new());
18541855
if expr_is_call && expr_snippet.starts_with("(") && expr_snippet.ends_with(")") {

0 commit comments

Comments
 (0)