]> git.lizzy.rs Git - rust.git/commitdiff
add negative test case in assignment-expected-bool
authorMazdak Farrokhzad <twingoow@gmail.com>
Wed, 27 Mar 2019 09:19:35 +0000 (10:19 +0100)
committerMazdak Farrokhzad <twingoow@gmail.com>
Wed, 27 Mar 2019 09:19:47 +0000 (10:19 +0100)
src/test/ui/type/type-check/assignment-expected-bool.rs
src/test/ui/type/type-check/assignment-expected-bool.stderr

index bb5ee46c9e17a339fbe54fcd02e9027fe9090590..03830fea062cf7d660f63c0da91af450a45d703b 100644 (file)
@@ -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]
 }
index e92973573488946d9acd52270d84c2666709cb96..fed8b913465827c3547b116a6603700163b45988 100644 (file)
@@ -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`.