]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/type/type-check/assignment-in-if.rs
1 // Test that the parser does not attempt to parse struct literals
2 // within assignments in if expressions.
4 #![allow(unused_parens)]
14 // `x { ... }` should not be interpreted as a struct literal here
16 //~^ ERROR mismatched types
19 // Explicit parentheses on the left should match behavior of above
21 //~^ ERROR mismatched types
24 // The struct literal interpretation is fine with explicit parentheses on the right
25 if y
= (Foo { foo: x }
) {
26 //~^ ERROR mismatched types
29 // "invalid left-hand side of assignment" error is suppresed
31 //~^ ERROR mismatched types
36 x
= 4 //~ ERROR mismatched types
38 x
= 5 //~ ERROR mismatched types
44 if x
== x
&& x
= x
&& x
== x
{
45 //~^ ERROR mismatched types
46 //~| ERROR mismatched types
47 //~| ERROR mismatched types
51 if x
== x
&& x
== x
&& x
= x
{
52 //~^ ERROR mismatched types
53 //~| ERROR mismatched types
58 //~^ ERROR mismatched types
59 //~| ERROR mismatched types