about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVitaly _Vi Shukela <vi0oss@gmail.com>2018-09-13 15:54:25 +0300
committerVitaly _Vi Shukela <vi0oss@gmail.com>2018-09-13 15:54:25 +0300
commit888b8c9451a41cccc8bdceee6423ee9d9e66bb43 (patch)
treebf7b4e819b0cdbb58b292fe7d77f20a8ca519a0f
parent636f518aac7430406dcb410cd7e46b4a217c265c (diff)
downloadrust-888b8c9451a41cccc8bdceee6423ee9d9e66bb43.tar.gz
rust-888b8c9451a41cccc8bdceee6423ee9d9e66bb43.zip
Add tests for issue 54109
-rw-r--r--src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.rs48
-rw-r--r--src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.stderr38
2 files changed, 86 insertions, 0 deletions
diff --git a/src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.rs b/src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.rs
new file mode 100644
index 00000000000..cb378455294
--- /dev/null
+++ b/src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.rs
@@ -0,0 +1,48 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn test_and() {
+    let a = true;
+    let b = false;
+    if a and b {
+        //~^ ERROR expected `{`, found `and`
+        println!("both");
+    }
+}
+
+fn test_or() {
+    let a = true;
+    let b = false;
+    if a or b {
+        //~^ ERROR expected `{`, found `or`
+        println!("both");
+    }
+}
+
+fn test_and_par() {
+    let a = true;
+    let b = false;
+    if (a and b) {
+        //~^ ERROR expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `and`
+        println!("both");
+    }
+}
+
+fn test_or_par() {
+    let a = true;
+    let b = false;
+    if (a or b) {
+        //~^ ERROR expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `or`
+        println!("both");
+    }
+}
+
+fn main() {
+}
diff --git a/src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.stderr b/src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.stderr
new file mode 100644
index 00000000000..9d53cc237e2
--- /dev/null
+++ b/src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.stderr
@@ -0,0 +1,38 @@
+error: expected `{`, found `and`
+  --> $DIR/issue-54109-and_instead_of_ampersands.rs:14:10
+   |
+LL |     if a and b {
+   |     --   ^^^
+   |     |
+   |     this `if` statement has a condition, but no block
+   |
+   = help: Use `&&` instead of `and` for the boolean operator
+
+error: expected `{`, found `or`
+  --> $DIR/issue-54109-and_instead_of_ampersands.rs:23:10
+   |
+LL |     if a or b {
+   |     --   ^^
+   |     |
+   |     this `if` statement has a condition, but no block
+   |
+   = help: Use `||` instead of `or` for the boolean operator
+
+error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `and`
+  --> $DIR/issue-54109-and_instead_of_ampersands.rs:32:11
+   |
+LL |     if (a and b) {
+   |           ^^^ expected one of 8 possible tokens here
+   |
+   = help: Use `&&` instead of `and` for the boolean operator
+
+error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `or`
+  --> $DIR/issue-54109-and_instead_of_ampersands.rs:41:11
+   |
+LL |     if (a or b) {
+   |           ^^ expected one of 8 possible tokens here
+   |
+   = help: Use `||` instead of `or` for the boolean operator
+
+error: aborting due to 4 previous errors
+