Add tests for struct literals in if let/while let

This commit is contained in:
Matthew Jasper 2023-08-28 10:30:48 +01:00
parent 7e02fd8251
commit 56c17dc280
4 changed files with 44 additions and 2 deletions

View file

@ -14,4 +14,9 @@ fn main() {
}.hi() {
println!("yo");
}
if let true = Foo { //~ ERROR struct literals are not allowed here
x: 3
}.hi() {
println!("yo");
}
}

View file

@ -14,5 +14,21 @@ LL | x: 3
LL ~ }).hi() {
|
error: aborting due to previous error
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

View file

@ -14,4 +14,9 @@ fn main() {
}.hi() {
println!("yo");
}
while let true = Foo { //~ ERROR struct literals are not allowed here
x: 3
}.hi() {
println!("yo");
}
}

View file

@ -14,5 +14,21 @@ LL | x: 3
LL ~ }).hi() {
|
error: aborting due to previous error
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