implement recovery in check_assoc_op
This commit is contained in:
parent
903c9dfd18
commit
52acaa6974
5 changed files with 100 additions and 92 deletions
|
|
@ -1,17 +1,25 @@
|
|||
fn main() {}
|
||||
|
||||
fn test_and() {
|
||||
let a = true;
|
||||
let b = false;
|
||||
if a and b {
|
||||
//~^ ERROR expected `{`, found `and`
|
||||
|
||||
let _ = a and b; //~ ERROR `and` is not a logical operator
|
||||
|
||||
if a and b { //~ ERROR `and` is not a logical operator
|
||||
println!("both");
|
||||
}
|
||||
|
||||
let _recovery_witness: () = 0; //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn test_or() {
|
||||
let a = true;
|
||||
let b = false;
|
||||
if a or b {
|
||||
//~^ ERROR expected `{`, found `or`
|
||||
|
||||
let _ = a or b; //~ ERROR `or` is not a logical operator
|
||||
|
||||
if a or b { //~ ERROR `or` is not a logical operator
|
||||
println!("both");
|
||||
}
|
||||
}
|
||||
|
|
@ -19,8 +27,7 @@ fn test_or() {
|
|||
fn test_and_par() {
|
||||
let a = true;
|
||||
let b = false;
|
||||
if (a and b) {
|
||||
//~^ ERROR expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `and`
|
||||
if (a and b) { //~ ERROR `and` is not a logical operator
|
||||
println!("both");
|
||||
}
|
||||
}
|
||||
|
|
@ -28,8 +35,7 @@ fn test_and_par() {
|
|||
fn test_or_par() {
|
||||
let a = true;
|
||||
let b = false;
|
||||
if (a or b) {
|
||||
//~^ ERROR expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `or`
|
||||
if (a or b) { //~ ERROR `or` is not a logical operator
|
||||
println!("both");
|
||||
}
|
||||
}
|
||||
|
|
@ -37,8 +43,7 @@ fn test_or_par() {
|
|||
fn test_while_and() {
|
||||
let a = true;
|
||||
let b = false;
|
||||
while a and b {
|
||||
//~^ ERROR expected one of `!`, `.`, `::`, `?`, `{`, or an operator, found `and`
|
||||
while a and b { //~ ERROR `and` is not a logical operator
|
||||
println!("both");
|
||||
}
|
||||
}
|
||||
|
|
@ -46,11 +51,7 @@ fn test_while_and() {
|
|||
fn test_while_or() {
|
||||
let a = true;
|
||||
let b = false;
|
||||
while a or b {
|
||||
//~^ ERROR expected one of `!`, `.`, `::`, `?`, `{`, or an operator, found `or`
|
||||
while a or b { //~ ERROR `or` is not a logical operator
|
||||
println!("both");
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,58 +1,75 @@
|
|||
error: expected `{`, found `and`
|
||||
--> $DIR/issue-54109-and_instead_of_ampersands.rs:4:10
|
||||
error: `and` is not a logical operator
|
||||
--> $DIR/issue-54109-and_instead_of_ampersands.rs:7:15
|
||||
|
|
||||
LL | let _ = a and b;
|
||||
| ^^^ help: instead of `and`, use `&&` to perform logical conjunction: `&&`
|
||||
|
|
||||
= note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators
|
||||
|
||||
error: `and` is not a logical operator
|
||||
--> $DIR/issue-54109-and_instead_of_ampersands.rs:9:10
|
||||
|
|
||||
LL | if a and b {
|
||||
| -- ^^^
|
||||
| | |
|
||||
| | expected `{`
|
||||
| | help: use `&&` instead of `and` for the boolean operator
|
||||
| this `if` statement has a condition, but no block
|
||||
| ^^^ help: instead of `and`, use `&&` to perform logical conjunction: `&&`
|
||||
|
|
||||
= note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators
|
||||
|
||||
error: expected `{`, found `or`
|
||||
--> $DIR/issue-54109-and_instead_of_ampersands.rs:13:10
|
||||
error: `or` is not a logical operator
|
||||
--> $DIR/issue-54109-and_instead_of_ampersands.rs:20:15
|
||||
|
|
||||
LL | let _ = a or b;
|
||||
| ^^ help: instead of `or`, use `||` to perform logical disjunction: `||`
|
||||
|
|
||||
= note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators
|
||||
|
||||
error: `or` is not a logical operator
|
||||
--> $DIR/issue-54109-and_instead_of_ampersands.rs:22:10
|
||||
|
|
||||
LL | if a or b {
|
||||
| -- ^^
|
||||
| | |
|
||||
| | expected `{`
|
||||
| | help: use `||` instead of `or` for the boolean operator
|
||||
| this `if` statement has a condition, but no block
|
||||
| ^^ help: instead of `or`, use `||` to perform logical disjunction: `||`
|
||||
|
|
||||
= note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators
|
||||
|
||||
error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `and`
|
||||
--> $DIR/issue-54109-and_instead_of_ampersands.rs:22:11
|
||||
error: `and` is not a logical operator
|
||||
--> $DIR/issue-54109-and_instead_of_ampersands.rs:30:11
|
||||
|
|
||||
LL | if (a and b) {
|
||||
| ^^^
|
||||
| |
|
||||
| expected one of 8 possible tokens
|
||||
| help: use `&&` instead of `and` for the boolean operator
|
||||
| ^^^ help: instead of `and`, use `&&` to perform logical conjunction: `&&`
|
||||
|
|
||||
= note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators
|
||||
|
||||
error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `or`
|
||||
--> $DIR/issue-54109-and_instead_of_ampersands.rs:31:11
|
||||
error: `or` is not a logical operator
|
||||
--> $DIR/issue-54109-and_instead_of_ampersands.rs:38:11
|
||||
|
|
||||
LL | if (a or b) {
|
||||
| ^^
|
||||
| |
|
||||
| expected one of 8 possible tokens
|
||||
| help: use `||` instead of `or` for the boolean operator
|
||||
| ^^ help: instead of `or`, use `||` to perform logical disjunction: `||`
|
||||
|
|
||||
= note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators
|
||||
|
||||
error: expected one of `!`, `.`, `::`, `?`, `{`, or an operator, found `and`
|
||||
--> $DIR/issue-54109-and_instead_of_ampersands.rs:40:13
|
||||
error: `and` is not a logical operator
|
||||
--> $DIR/issue-54109-and_instead_of_ampersands.rs:46:13
|
||||
|
|
||||
LL | while a and b {
|
||||
| ^^^
|
||||
| |
|
||||
| expected one of `!`, `.`, `::`, `?`, `{`, or an operator
|
||||
| help: use `&&` instead of `and` for the boolean operator
|
||||
| ^^^ help: instead of `and`, use `&&` to perform logical conjunction: `&&`
|
||||
|
|
||||
= note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators
|
||||
|
||||
error: expected one of `!`, `.`, `::`, `?`, `{`, or an operator, found `or`
|
||||
--> $DIR/issue-54109-and_instead_of_ampersands.rs:49:13
|
||||
error: `or` is not a logical operator
|
||||
--> $DIR/issue-54109-and_instead_of_ampersands.rs:54:13
|
||||
|
|
||||
LL | while a or b {
|
||||
| ^^
|
||||
| |
|
||||
| expected one of `!`, `.`, `::`, `?`, `{`, or an operator
|
||||
| help: use `||` instead of `or` for the boolean operator
|
||||
| ^^ help: instead of `or`, use `||` to perform logical disjunction: `||`
|
||||
|
|
||||
= note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-54109-and_instead_of_ampersands.rs:13:33
|
||||
|
|
||||
LL | let _recovery_witness: () = 0;
|
||||
| -- ^ expected `()`, found integer
|
||||
| |
|
||||
| expected due to this
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue