From 43b79d8ef5e1967a7ea476b757256d62fdbb3ebf Mon Sep 17 00:00:00 2001 From: Andrew Hickman Date: Sat, 11 Sep 2021 10:08:11 +0100 Subject: [PATCH] Add comment pointing to test --- compiler/rustc_typeck/src/check/op.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/rustc_typeck/src/check/op.rs b/compiler/rustc_typeck/src/check/op.rs index bc5587af3efb..a574a63d63b2 100644 --- a/compiler/rustc_typeck/src/check/op.rs +++ b/compiler/rustc_typeck/src/check/op.rs @@ -685,6 +685,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some(sp) = self.tcx.sess.parse_sess.ambiguous_block_expr_parse.borrow().get(&sp) { + // If the previous expression was a block expression, suggest parentheses + // (turning this into a binary subtraction operation instead.) + // for example, `{2} - 2` -> `({2}) - 2` (see src\test\ui\parser\expr-as-stmt.rs) self.tcx.sess.parse_sess.expr_parentheses_needed(&mut err, *sp); } else { match actual.kind() {