about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/parser/closure-return-syntax.rs16
-rw-r--r--tests/ui/parser/closure-return-syntax.stderr24
2 files changed, 38 insertions, 2 deletions
diff --git a/tests/ui/parser/closure-return-syntax.rs b/tests/ui/parser/closure-return-syntax.rs
index c6a08abeff4..6865d8c5393 100644
--- a/tests/ui/parser/closure-return-syntax.rs
+++ b/tests/ui/parser/closure-return-syntax.rs
@@ -1,7 +1,21 @@
 // Test that we cannot parse a closure with an explicit return type
 // unless it uses braces.
 
-fn main() {
+fn needs_braces_1() {
     let x = || -> i32 22;
     //~^ ERROR expected `{`, found `22`
 }
+
+// Check other delimiters too.
+
+fn needs_braces_2() {
+        let x = || -> (i32, i32) (1, 2);
+        //~^ ERROR expected `{`, found `(`
+}
+
+fn needs_braces_3() {
+        let c = || -> [i32; 2] [1, 2];
+        //~^ ERROR expected `{`, found `[`
+}
+
+fn main() {}
diff --git a/tests/ui/parser/closure-return-syntax.stderr b/tests/ui/parser/closure-return-syntax.stderr
index aacc31ed871..6f2106b77ad 100644
--- a/tests/ui/parser/closure-return-syntax.stderr
+++ b/tests/ui/parser/closure-return-syntax.stderr
@@ -9,5 +9,27 @@ help: you might have meant to write this as part of a block
 LL |     let x = || -> i32 { 22 };
    |                       +    +
 
-error: aborting due to 1 previous error
+error: expected `{`, found `(`
+  --> $DIR/closure-return-syntax.rs:12:34
+   |
+LL |         let x = || -> (i32, i32) (1, 2);
+   |                                  ^ expected `{`
+   |
+help: you might have meant to write this as part of a block
+   |
+LL |         let x = || -> (i32, i32) { (1, 2) };
+   |                                  +        +
+
+error: expected `{`, found `[`
+  --> $DIR/closure-return-syntax.rs:17:32
+   |
+LL |         let c = || -> [i32; 2] [1, 2];
+   |                                ^ expected `{`
+   |
+help: you might have meant to write this as part of a block
+   |
+LL |         let c = || -> [i32; 2] { [1, 2] };
+   |                                +        +
+
+error: aborting due to 3 previous errors