about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/ui/parser/method-call-on-struct-literal-in-if-condition.rs13
-rw-r--r--tests/ui/parser/method-call-on-struct-literal-in-if-condition.stderr13
-rw-r--r--tests/ui/parser/struct-literal-in-for.rs17
-rw-r--r--tests/ui/parser/struct-literal-in-for.stderr31
-rw-r--r--tests/ui/parser/struct-literal-in-if.rs22
-rw-r--r--tests/ui/parser/struct-literal-in-if.stderr34
-rw-r--r--tests/ui/parser/struct-literal-in-match-discriminant.rs13
-rw-r--r--tests/ui/parser/struct-literal-in-match-discriminant.stderr18
-rw-r--r--tests/ui/parser/struct-literal-in-while.rs22
-rw-r--r--tests/ui/parser/struct-literal-in-while.stderr34
-rw-r--r--tests/ui/parser/struct-literal-restrictions-in-lamda.rs17
-rw-r--r--tests/ui/parser/struct-literal-restrictions-in-lamda.stderr37
-rw-r--r--tests/ui/parser/struct-literal-variant-in-if.rs25
-rw-r--r--tests/ui/parser/struct-literal-variant-in-if.stderr76
-rw-r--r--tests/ui/parser/struct-literals-in-invalid-places.rs72
-rw-r--r--tests/ui/parser/struct-literals-in-invalid-places.stderr191
16 files changed, 263 insertions, 372 deletions
diff --git a/tests/ui/parser/method-call-on-struct-literal-in-if-condition.rs b/tests/ui/parser/method-call-on-struct-literal-in-if-condition.rs
deleted file mode 100644
index 3211b6c7bb9..00000000000
--- a/tests/ui/parser/method-call-on-struct-literal-in-if-condition.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-pub struct Example { a: i32 }
-
-impl Example {
-    fn is_pos(&self) -> bool { self.a > 0 }
-}
-
-fn one() -> i32 { 1 }
-
-fn main() {
-    if Example { a: one(), }.is_pos() { //~ ERROR struct literals are not allowed here
-        println!("Positive!");
-    }
-}
diff --git a/tests/ui/parser/method-call-on-struct-literal-in-if-condition.stderr b/tests/ui/parser/method-call-on-struct-literal-in-if-condition.stderr
deleted file mode 100644
index 8eba2230f8f..00000000000
--- a/tests/ui/parser/method-call-on-struct-literal-in-if-condition.stderr
+++ /dev/null
@@ -1,13 +0,0 @@
-error: struct literals are not allowed here
-  --> $DIR/method-call-on-struct-literal-in-if-condition.rs:10:8
-   |
-LL |     if Example { a: one(), }.is_pos() {
-   |        ^^^^^^^^^^^^^^^^^^^^^
-   |
-help: surround the struct literal with parentheses
-   |
-LL |     if (Example { a: one(), }).is_pos() {
-   |        +                     +
-
-error: aborting due to 1 previous error
-
diff --git a/tests/ui/parser/struct-literal-in-for.rs b/tests/ui/parser/struct-literal-in-for.rs
deleted file mode 100644
index 3227ae37bfd..00000000000
--- a/tests/ui/parser/struct-literal-in-for.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-struct Foo {
-    x: isize,
-}
-
-impl Foo {
-    fn hi(&self) -> bool {
-        true
-    }
-}
-
-fn main() {
-    for x in Foo { //~ ERROR struct literals are not allowed here
-        x: 3       //~^ ERROR `bool` is not an iterator
-    }.hi() {
-        println!("yo");
-    }
-}
diff --git a/tests/ui/parser/struct-literal-in-for.stderr b/tests/ui/parser/struct-literal-in-for.stderr
deleted file mode 100644
index 1c91eba68e3..00000000000
--- a/tests/ui/parser/struct-literal-in-for.stderr
+++ /dev/null
@@ -1,31 +0,0 @@
-error: struct literals are not allowed here
-  --> $DIR/struct-literal-in-for.rs:12:14
-   |
-LL |       for x in Foo {
-   |  ______________^
-LL | |         x: 3
-LL | |     }.hi() {
-   | |_____^
-   |
-help: surround the struct literal with parentheses
-   |
-LL ~     for x in (Foo {
-LL |         x: 3
-LL ~     }).hi() {
-   |
-
-error[E0277]: `bool` is not an iterator
-  --> $DIR/struct-literal-in-for.rs:12:14
-   |
-LL |       for x in Foo {
-   |  ______________^
-LL | |         x: 3
-LL | |     }.hi() {
-   | |__________^ `bool` is not an iterator
-   |
-   = help: the trait `Iterator` is not implemented for `bool`
-   = note: required for `bool` to implement `IntoIterator`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/parser/struct-literal-in-if.rs b/tests/ui/parser/struct-literal-in-if.rs
deleted file mode 100644
index c4a253c3da2..00000000000
--- a/tests/ui/parser/struct-literal-in-if.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-struct Foo {
-    x: isize,
-}
-
-impl Foo {
-    fn hi(&self) -> bool {
-        true
-    }
-}
-
-fn main() {
-    if Foo { //~ ERROR struct literals are not allowed here
-        x: 3
-    }.hi() {
-        println!("yo");
-    }
-    if let true = Foo { //~ ERROR struct literals are not allowed here
-        x: 3
-    }.hi() {
-        println!("yo");
-    }
-}
diff --git a/tests/ui/parser/struct-literal-in-if.stderr b/tests/ui/parser/struct-literal-in-if.stderr
deleted file mode 100644
index 8b72469fcf5..00000000000
--- a/tests/ui/parser/struct-literal-in-if.stderr
+++ /dev/null
@@ -1,34 +0,0 @@
-error: struct literals are not allowed here
-  --> $DIR/struct-literal-in-if.rs:12:8
-   |
-LL |       if Foo {
-   |  ________^
-LL | |         x: 3
-LL | |     }.hi() {
-   | |_____^
-   |
-help: surround the struct literal with parentheses
-   |
-LL ~     if (Foo {
-LL |         x: 3
-LL ~     }).hi() {
-   |
-
-error: struct literals are not allowed here
-  --> $DIR/struct-literal-in-if.rs:17:19
-   |
-LL |       if let true = Foo {
-   |  ___________________^
-LL | |         x: 3
-LL | |     }.hi() {
-   | |_____^
-   |
-help: surround the struct literal with parentheses
-   |
-LL ~     if let true = (Foo {
-LL |         x: 3
-LL ~     }).hi() {
-   |
-
-error: aborting due to 2 previous errors
-
diff --git a/tests/ui/parser/struct-literal-in-match-discriminant.rs b/tests/ui/parser/struct-literal-in-match-discriminant.rs
deleted file mode 100644
index ce132df5a88..00000000000
--- a/tests/ui/parser/struct-literal-in-match-discriminant.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-struct Foo {
-    x: isize,
-}
-
-fn main() {
-    match Foo { //~ ERROR struct literals are not allowed here
-        x: 3
-    } {
-        Foo {
-            x: x
-        } => {}
-    }
-}
diff --git a/tests/ui/parser/struct-literal-in-match-discriminant.stderr b/tests/ui/parser/struct-literal-in-match-discriminant.stderr
deleted file mode 100644
index 5177f5f126e..00000000000
--- a/tests/ui/parser/struct-literal-in-match-discriminant.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error: struct literals are not allowed here
-  --> $DIR/struct-literal-in-match-discriminant.rs:6:11
-   |
-LL |       match Foo {
-   |  ___________^
-LL | |         x: 3
-LL | |     } {
-   | |_____^
-   |
-help: surround the struct literal with parentheses
-   |
-LL ~     match (Foo {
-LL |         x: 3
-LL ~     }) {
-   |
-
-error: aborting due to 1 previous error
-
diff --git a/tests/ui/parser/struct-literal-in-while.rs b/tests/ui/parser/struct-literal-in-while.rs
deleted file mode 100644
index 86931f7888d..00000000000
--- a/tests/ui/parser/struct-literal-in-while.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-struct Foo {
-    x: isize,
-}
-
-impl Foo {
-    fn hi(&self) -> bool {
-        true
-    }
-}
-
-fn main() {
-    while Foo { //~ ERROR struct literals are not allowed here
-        x: 3
-    }.hi() {
-        println!("yo");
-    }
-    while let true = Foo { //~ ERROR struct literals are not allowed here
-        x: 3
-    }.hi() {
-        println!("yo");
-    }
-}
diff --git a/tests/ui/parser/struct-literal-in-while.stderr b/tests/ui/parser/struct-literal-in-while.stderr
deleted file mode 100644
index 13d003608a1..00000000000
--- a/tests/ui/parser/struct-literal-in-while.stderr
+++ /dev/null
@@ -1,34 +0,0 @@
-error: struct literals are not allowed here
-  --> $DIR/struct-literal-in-while.rs:12:11
-   |
-LL |       while Foo {
-   |  ___________^
-LL | |         x: 3
-LL | |     }.hi() {
-   | |_____^
-   |
-help: surround the struct literal with parentheses
-   |
-LL ~     while (Foo {
-LL |         x: 3
-LL ~     }).hi() {
-   |
-
-error: struct literals are not allowed here
-  --> $DIR/struct-literal-in-while.rs:17:22
-   |
-LL |       while let true = Foo {
-   |  ______________________^
-LL | |         x: 3
-LL | |     }.hi() {
-   | |_____^
-   |
-help: surround the struct literal with parentheses
-   |
-LL ~     while let true = (Foo {
-LL |         x: 3
-LL ~     }).hi() {
-   |
-
-error: aborting due to 2 previous errors
-
diff --git a/tests/ui/parser/struct-literal-restrictions-in-lamda.rs b/tests/ui/parser/struct-literal-restrictions-in-lamda.rs
deleted file mode 100644
index e185153dcf6..00000000000
--- a/tests/ui/parser/struct-literal-restrictions-in-lamda.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-struct Foo {
-    x: isize,
-}
-
-impl Foo {
-    fn hi(&self) -> bool {
-        true
-    }
-}
-
-fn main() {
-    while || Foo { //~ ERROR struct literals are not allowed here
-        x: 3       //~^ ERROR mismatched types
-    }.hi() {
-        println!("yo");
-    }
-}
diff --git a/tests/ui/parser/struct-literal-restrictions-in-lamda.stderr b/tests/ui/parser/struct-literal-restrictions-in-lamda.stderr
deleted file mode 100644
index c715486e2da..00000000000
--- a/tests/ui/parser/struct-literal-restrictions-in-lamda.stderr
+++ /dev/null
@@ -1,37 +0,0 @@
-error: struct literals are not allowed here
-  --> $DIR/struct-literal-restrictions-in-lamda.rs:12:14
-   |
-LL |       while || Foo {
-   |  ______________^
-LL | |         x: 3
-LL | |     }.hi() {
-   | |_____^
-   |
-help: surround the struct literal with parentheses
-   |
-LL ~     while || (Foo {
-LL |         x: 3
-LL ~     }).hi() {
-   |
-
-error[E0308]: mismatched types
-  --> $DIR/struct-literal-restrictions-in-lamda.rs:12:11
-   |
-LL |       while || Foo {
-   |  ___________^
-LL | |         x: 3
-LL | |     }.hi() {
-   | |__________^ expected `bool`, found closure
-   |
-   = note: expected type `bool`
-           found closure `{closure@$DIR/struct-literal-restrictions-in-lamda.rs:12:11: 12:13}`
-help: use parentheses to call this closure
-   |
-LL ~     while (|| Foo {
-LL |         x: 3
-LL ~     }.hi())() {
-   |
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/parser/struct-literal-variant-in-if.rs b/tests/ui/parser/struct-literal-variant-in-if.rs
deleted file mode 100644
index 4ef8effaf1f..00000000000
--- a/tests/ui/parser/struct-literal-variant-in-if.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
-enum E {
-    V { field: bool },
-    I { field1: bool, field2: usize },
-    J { field: isize },
-    K { field: &'static str},
-}
-fn test_E(x: E) {
-    let field = true;
-    if x == E::V { field } {}
-    //~^ ERROR expected value, found struct variant `E::V`
-    //~| ERROR mismatched types
-    if x == E::I { field1: true, field2: 42 } {}
-    //~^ ERROR struct literals are not allowed here
-    if x == E::V { field: false } {}
-    //~^ ERROR struct literals are not allowed here
-    if x == E::J { field: -42 } {}
-    //~^ ERROR struct literals are not allowed here
-    if x == E::K { field: "" } {}
-    //~^ ERROR struct literals are not allowed here
-    let y: usize = ();
-    //~^ ERROR mismatched types
-}
-
-fn main() {}
diff --git a/tests/ui/parser/struct-literal-variant-in-if.stderr b/tests/ui/parser/struct-literal-variant-in-if.stderr
deleted file mode 100644
index 15f059f145b..00000000000
--- a/tests/ui/parser/struct-literal-variant-in-if.stderr
+++ /dev/null
@@ -1,76 +0,0 @@
-error: struct literals are not allowed here
-  --> $DIR/struct-literal-variant-in-if.rs:13:13
-   |
-LL |     if x == E::I { field1: true, field2: 42 } {}
-   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-help: surround the struct literal with parentheses
-   |
-LL |     if x == (E::I { field1: true, field2: 42 }) {}
-   |             +                                 +
-
-error: struct literals are not allowed here
-  --> $DIR/struct-literal-variant-in-if.rs:15:13
-   |
-LL |     if x == E::V { field: false } {}
-   |             ^^^^^^^^^^^^^^^^^^^^^
-   |
-help: surround the struct literal with parentheses
-   |
-LL |     if x == (E::V { field: false }) {}
-   |             +                     +
-
-error: struct literals are not allowed here
-  --> $DIR/struct-literal-variant-in-if.rs:17:13
-   |
-LL |     if x == E::J { field: -42 } {}
-   |             ^^^^^^^^^^^^^^^^^^^
-   |
-help: surround the struct literal with parentheses
-   |
-LL |     if x == (E::J { field: -42 }) {}
-   |             +                   +
-
-error: struct literals are not allowed here
-  --> $DIR/struct-literal-variant-in-if.rs:19:13
-   |
-LL |     if x == E::K { field: "" } {}
-   |             ^^^^^^^^^^^^^^^^^^
-   |
-help: surround the struct literal with parentheses
-   |
-LL |     if x == (E::K { field: "" }) {}
-   |             +                  +
-
-error[E0533]: expected value, found struct variant `E::V`
-  --> $DIR/struct-literal-variant-in-if.rs:10:13
-   |
-LL |     if x == E::V { field } {}
-   |             ^^^^ not a value
-   |
-help: you might have meant to create a new value of the struct
-   |
-LL |     if x == (E::V { field }) {}
-   |             +              +
-
-error[E0308]: mismatched types
-  --> $DIR/struct-literal-variant-in-if.rs:10:20
-   |
-LL |     if x == E::V { field } {}
-   |     ---------------^^^^^--
-   |     |              |
-   |     |              expected `()`, found `bool`
-   |     expected this to be `()`
-
-error[E0308]: mismatched types
-  --> $DIR/struct-literal-variant-in-if.rs:21:20
-   |
-LL |     let y: usize = ();
-   |            -----   ^^ expected `usize`, found `()`
-   |            |
-   |            expected due to this
-
-error: aborting due to 7 previous errors
-
-Some errors have detailed explanations: E0308, E0533.
-For more information about an error, try `rustc --explain E0308`.
diff --git a/tests/ui/parser/struct-literals-in-invalid-places.rs b/tests/ui/parser/struct-literals-in-invalid-places.rs
new file mode 100644
index 00000000000..89cdb30fc04
--- /dev/null
+++ b/tests/ui/parser/struct-literals-in-invalid-places.rs
@@ -0,0 +1,72 @@
+fn main() {
+    if Foo { x: 3 }.hi() { //~ ERROR struct literals are not allowed here
+        println!("yo");
+    }
+    if let true = Foo { x: 3 }.hi() { //~ ERROR struct literals are not allowed here
+        println!("yo");
+    }
+
+    for x in Foo { x: 3 }.hi() { //~ ERROR struct literals are not allowed here
+        //~^ ERROR `bool` is not an iterator
+        println!("yo");
+    }
+
+    while Foo { x: 3 }.hi() { //~ ERROR struct literals are not allowed here
+        println!("yo");
+    }
+    while let true = Foo { x: 3 }.hi() { //~ ERROR struct literals are not allowed here
+        println!("yo");
+    }
+
+    match Foo { x: 3 } { //~ ERROR struct literals are not allowed here
+        Foo { x: x } => {}
+    }
+
+    let _ = |x: E| {
+        let field = true;
+        if x == E::V { field } {}
+        //~^ ERROR expected value, found struct variant `E::V`
+        //~| ERROR mismatched types
+        if x == E::I { field1: true, field2: 42 } {}
+        //~^ ERROR struct literals are not allowed here
+        if x == E::V { field: false } {}
+        //~^ ERROR struct literals are not allowed here
+        if x == E::J { field: -42 } {}
+        //~^ ERROR struct literals are not allowed here
+        if x == E::K { field: "" } {}
+        //~^ ERROR struct literals are not allowed here
+        let y: usize = ();
+        //~^ ERROR mismatched types
+    };
+
+    // Regression test for <https://github.com/rust-lang/rust/issues/43412>.
+    while || Foo { x: 3 }.hi() { //~ ERROR struct literals are not allowed here
+        //~^ ERROR mismatched types
+        println!("yo");
+    }
+
+    // Regression test for <https://github.com/rust-lang/rust/issues/82051>.
+    if Foo { x: one(), }.hi() { //~ ERROR struct literals are not allowed here
+        println!("Positive!");
+    }
+}
+
+struct Foo {
+    x: isize,
+}
+
+impl Foo {
+    fn hi(&self) -> bool {
+        true
+    }
+}
+
+#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
+enum E {
+    V { field: bool },
+    I { field1: bool, field2: usize },
+    J { field: isize },
+    K { field: &'static str},
+}
+
+fn one() -> isize { 1 }
diff --git a/tests/ui/parser/struct-literals-in-invalid-places.stderr b/tests/ui/parser/struct-literals-in-invalid-places.stderr
new file mode 100644
index 00000000000..ed094fc3e15
--- /dev/null
+++ b/tests/ui/parser/struct-literals-in-invalid-places.stderr
@@ -0,0 +1,191 @@
+error: struct literals are not allowed here
+  --> $DIR/struct-literals-in-invalid-places.rs:2:8
+   |
+LL |     if Foo { x: 3 }.hi() {
+   |        ^^^^^^^^^^^^
+   |
+help: surround the struct literal with parentheses
+   |
+LL |     if (Foo { x: 3 }).hi() {
+   |        +            +
+
+error: struct literals are not allowed here
+  --> $DIR/struct-literals-in-invalid-places.rs:5:19
+   |
+LL |     if let true = Foo { x: 3 }.hi() {
+   |                   ^^^^^^^^^^^^
+   |
+help: surround the struct literal with parentheses
+   |
+LL |     if let true = (Foo { x: 3 }).hi() {
+   |                   +            +
+
+error: struct literals are not allowed here
+  --> $DIR/struct-literals-in-invalid-places.rs:9:14
+   |
+LL |     for x in Foo { x: 3 }.hi() {
+   |              ^^^^^^^^^^^^
+   |
+help: surround the struct literal with parentheses
+   |
+LL |     for x in (Foo { x: 3 }).hi() {
+   |              +            +
+
+error: struct literals are not allowed here
+  --> $DIR/struct-literals-in-invalid-places.rs:14:11
+   |
+LL |     while Foo { x: 3 }.hi() {
+   |           ^^^^^^^^^^^^
+   |
+help: surround the struct literal with parentheses
+   |
+LL |     while (Foo { x: 3 }).hi() {
+   |           +            +
+
+error: struct literals are not allowed here
+  --> $DIR/struct-literals-in-invalid-places.rs:17:22
+   |
+LL |     while let true = Foo { x: 3 }.hi() {
+   |                      ^^^^^^^^^^^^
+   |
+help: surround the struct literal with parentheses
+   |
+LL |     while let true = (Foo { x: 3 }).hi() {
+   |                      +            +
+
+error: struct literals are not allowed here
+  --> $DIR/struct-literals-in-invalid-places.rs:21:11
+   |
+LL |     match Foo { x: 3 } {
+   |           ^^^^^^^^^^^^
+   |
+help: surround the struct literal with parentheses
+   |
+LL |     match (Foo { x: 3 }) {
+   |           +            +
+
+error: struct literals are not allowed here
+  --> $DIR/struct-literals-in-invalid-places.rs:30:17
+   |
+LL |         if x == E::I { field1: true, field2: 42 } {}
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: surround the struct literal with parentheses
+   |
+LL |         if x == (E::I { field1: true, field2: 42 }) {}
+   |                 +                                 +
+
+error: struct literals are not allowed here
+  --> $DIR/struct-literals-in-invalid-places.rs:32:17
+   |
+LL |         if x == E::V { field: false } {}
+   |                 ^^^^^^^^^^^^^^^^^^^^^
+   |
+help: surround the struct literal with parentheses
+   |
+LL |         if x == (E::V { field: false }) {}
+   |                 +                     +
+
+error: struct literals are not allowed here
+  --> $DIR/struct-literals-in-invalid-places.rs:34:17
+   |
+LL |         if x == E::J { field: -42 } {}
+   |                 ^^^^^^^^^^^^^^^^^^^
+   |
+help: surround the struct literal with parentheses
+   |
+LL |         if x == (E::J { field: -42 }) {}
+   |                 +                   +
+
+error: struct literals are not allowed here
+  --> $DIR/struct-literals-in-invalid-places.rs:36:17
+   |
+LL |         if x == E::K { field: "" } {}
+   |                 ^^^^^^^^^^^^^^^^^^
+   |
+help: surround the struct literal with parentheses
+   |
+LL |         if x == (E::K { field: "" }) {}
+   |                 +                  +
+
+error: struct literals are not allowed here
+  --> $DIR/struct-literals-in-invalid-places.rs:43:14
+   |
+LL |     while || Foo { x: 3 }.hi() {
+   |              ^^^^^^^^^^^^
+   |
+help: surround the struct literal with parentheses
+   |
+LL |     while || (Foo { x: 3 }).hi() {
+   |              +            +
+
+error: struct literals are not allowed here
+  --> $DIR/struct-literals-in-invalid-places.rs:49:8
+   |
+LL |     if Foo { x: one(), }.hi() {
+   |        ^^^^^^^^^^^^^^^^^
+   |
+help: surround the struct literal with parentheses
+   |
+LL |     if (Foo { x: one(), }).hi() {
+   |        +                 +
+
+error[E0277]: `bool` is not an iterator
+  --> $DIR/struct-literals-in-invalid-places.rs:9:14
+   |
+LL |     for x in Foo { x: 3 }.hi() {
+   |              ^^^^^^^^^^^^^^^^^ `bool` is not an iterator
+   |
+   = help: the trait `Iterator` is not implemented for `bool`
+   = note: required for `bool` to implement `IntoIterator`
+
+error[E0533]: expected value, found struct variant `E::V`
+  --> $DIR/struct-literals-in-invalid-places.rs:27:17
+   |
+LL |         if x == E::V { field } {}
+   |                 ^^^^ not a value
+   |
+help: you might have meant to create a new value of the struct
+   |
+LL |         if x == (E::V { field }) {}
+   |                 +              +
+
+error[E0308]: mismatched types
+  --> $DIR/struct-literals-in-invalid-places.rs:27:24
+   |
+LL |         if x == E::V { field } {}
+   |         ---------------^^^^^--
+   |         |              |
+   |         |              expected `()`, found `bool`
+   |         expected this to be `()`
+   |
+help: you might have meant to return this value
+   |
+LL |         if x == E::V { return field; } {}
+   |                        ++++++      +
+
+error[E0308]: mismatched types
+  --> $DIR/struct-literals-in-invalid-places.rs:38:24
+   |
+LL |         let y: usize = ();
+   |                -----   ^^ expected `usize`, found `()`
+   |                |
+   |                expected due to this
+
+error[E0308]: mismatched types
+  --> $DIR/struct-literals-in-invalid-places.rs:43:11
+   |
+LL |     while || Foo { x: 3 }.hi() {
+   |           ^^^^^^^^^^^^^^^^^^^^ expected `bool`, found closure
+   |
+   = note: expected type `bool`
+           found closure `{closure@$DIR/struct-literals-in-invalid-places.rs:43:11: 43:13}`
+help: use parentheses to call this closure
+   |
+LL |     while (|| Foo { x: 3 }.hi())() {
+   |           +                    +++
+
+error: aborting due to 17 previous errors
+
+Some errors have detailed explanations: E0277, E0308, E0533.
+For more information about an error, try `rustc --explain E0277`.