about summary refs log tree commit diff
path: root/tests/ui/parser
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-10-13 19:26:27 +0000
committerbors <bors@rust-lang.org>2023-10-13 19:26:27 +0000
commit09eff4488902242b8a4a86697d74ad4166ee9e7e (patch)
tree7cee3e90ec8ae7716fee38021dbc35c12c91c341 /tests/ui/parser
parent57ef8898520f7ff2c60341636bb86d94cb550e79 (diff)
parent6b2c6c7fd3860cc9e6fde3077b889abbd6a30892 (diff)
downloadrust-09eff4488902242b8a4a86697d74ad4166ee9e7e.tar.gz
rust-09eff4488902242b8a4a86697d74ad4166ee9e7e.zip
Auto merge of #116645 - estebank:issue-116608, r=oli-obk
Detect ruby-style closure in parser

When parsing a closure without a body that is surrounded by a block, suggest moving the opening brace after the closure head.

Fix #116608.
Diffstat (limited to 'tests/ui/parser')
-rw-r--r--tests/ui/parser/issues/issue-32505.rs1
-rw-r--r--tests/ui/parser/issues/issue-32505.stderr18
2 files changed, 17 insertions, 2 deletions
diff --git a/tests/ui/parser/issues/issue-32505.rs b/tests/ui/parser/issues/issue-32505.rs
index f31c00e5cc3..d95e7dc7d9e 100644
--- a/tests/ui/parser/issues/issue-32505.rs
+++ b/tests/ui/parser/issues/issue-32505.rs
@@ -1,5 +1,6 @@
 pub fn test() {
     foo(|_|) //~ ERROR expected expression, found `)`
+    //~^ ERROR cannot find function `foo` in this scope
 }
 
 fn main() { }
diff --git a/tests/ui/parser/issues/issue-32505.stderr b/tests/ui/parser/issues/issue-32505.stderr
index cdd779a93ef..27ad2c3e5be 100644
--- a/tests/ui/parser/issues/issue-32505.stderr
+++ b/tests/ui/parser/issues/issue-32505.stderr
@@ -2,7 +2,21 @@ error: expected expression, found `)`
   --> $DIR/issue-32505.rs:2:12
    |
 LL |     foo(|_|)
-   |            ^ expected expression
+   |         ---^ expected expression
+   |         |
+   |         while parsing the body of this closure
+   |
+help: you might have meant to open the body of the closure
+   |
+LL |     foo(|_| {})
+   |            ++
+
+error[E0425]: cannot find function `foo` in this scope
+  --> $DIR/issue-32505.rs:2:5
+   |
+LL |     foo(|_|)
+   |     ^^^ not found in this scope
 
-error: aborting due to previous error
+error: aborting due to 2 previous errors
 
+For more information about this error, try `rustc --explain E0425`.