diff options
| author | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-10-07 11:37:33 +0900 |
|---|---|---|
| committer | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-10-07 11:37:33 +0900 |
| commit | 57d0278d5cd397a89bb33f1857b3ed431c1f341c (patch) | |
| tree | cdc76b3539959ee43e29306b69332c1a9a0430f0 /src/test | |
| parent | 0ca356586fed56002b10920fd21ddf6fb12de797 (diff) | |
suggest `==` to the first expr which has `ExprKind::Assign`
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/type/type-check/assignment-in-if.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/type/type-check/assignment-in-if.stderr | 19 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/test/ui/type/type-check/assignment-in-if.rs b/src/test/ui/type/type-check/assignment-in-if.rs index 3a7845096fd..ada250df246 100644 --- a/src/test/ui/type/type-check/assignment-in-if.rs +++ b/src/test/ui/type/type-check/assignment-in-if.rs @@ -53,4 +53,10 @@ fn main() { //~| ERROR mismatched types println!("{}", x); } + + if x = 1 && x == 1 { + //~^ ERROR mismatched types + //~| ERROR mismatched types + println!("{}", x); + } } diff --git a/src/test/ui/type/type-check/assignment-in-if.stderr b/src/test/ui/type/type-check/assignment-in-if.stderr index 166f2293777..8ab08e25e30 100644 --- a/src/test/ui/type/type-check/assignment-in-if.stderr +++ b/src/test/ui/type/type-check/assignment-in-if.stderr @@ -104,6 +104,23 @@ help: you might have meant to compare for equality LL | if x == x && x == x && x == x { | + -error: aborting due to 11 previous errors +error[E0308]: mismatched types + --> $DIR/assignment-in-if.rs:57:12 + | +LL | if x = 1 && x == 1 { + | ^ expected `bool`, found integer + +error[E0308]: mismatched types + --> $DIR/assignment-in-if.rs:57:8 + | +LL | if x = 1 && x == 1 { + | ^^^^^^^^^^^^^^^ expected `bool`, found `()` + | +help: you might have meant to compare for equality + | +LL | if x == 1 && x == 1 { + | + + +error: aborting due to 13 previous errors For more information about this error, try `rustc --explain E0308`. |
