Add tests for struct literals in if let/while let
This commit is contained in:
parent
7e02fd8251
commit
56c17dc280
4 changed files with 44 additions and 2 deletions
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue