Skip to content

Commit

Permalink
add negative test case in assignment-expected-bool
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Mar 27, 2019
1 parent 0b9c589 commit ce1c5e0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/test/ui/type/type-check/assignment-expected-bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ fn main() {
let _ = (0 = 0) //~ ERROR mismatched types [E0308]
&& { 0 = 0 } //~ ERROR mismatched types [E0308]
|| (0 = 0); //~ ERROR mismatched types [E0308]

// A test to check that not expecting `bool` behaves well:
let _: usize = 0 = 0;
//~^ ERROR mismatched types [E0308]
//~| ERROR invalid left-hand side expression [E0070]
}
20 changes: 18 additions & 2 deletions src/test/ui/type/type-check/assignment-expected-bool.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,22 @@ LL | || (0 = 0);
= note: expected type `bool`
found type `()`

error: aborting due to 11 previous errors
error[E0070]: invalid left-hand side expression
--> $DIR/assignment-expected-bool.rs:31:20
|
LL | let _: usize = 0 = 0;
| ^^^^^ left-hand of expression not valid

error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:31:20
|
LL | let _: usize = 0 = 0;
| ^^^^^ expected usize, found ()
|
= note: expected type `usize`
found type `()`

error: aborting due to 13 previous errors

For more information about this error, try `rustc --explain E0308`.
Some errors occurred: E0070, E0308.
For more information about an error, try `rustc --explain E0070`.

0 comments on commit ce1c5e0

Please sign in to comment.