about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2019-01-20 04:37:58 +0900
committerYuki Okushi <huyuumi.dev@gmail.com>2019-01-20 04:37:58 +0900
commite9af312932baee90d260b41711f7ea95ad51bc07 (patch)
treea560d81df5059139b24431b21a91e72faa5beaf1 /src
parentc502a79fa1a15de88623bc01d9a1c38db3ea2c1b (diff)
downloadrust-e9af312932baee90d260b41711f7ea95ad51bc07.tar.gz
rust-e9af312932baee90d260b41711f7ea95ad51bc07.zip
[WIP] Fix tests
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/parser/lex-bad-char-literals-2.rs2
-rw-r--r--src/test/ui/parser/lex-bad-char-literals-2.stderr9
-rw-r--r--src/test/ui/parser/lex-bad-char-literals-4.rs2
-rw-r--r--src/test/ui/parser/lex-bad-char-literals-4.stderr16
-rw-r--r--src/test/ui/parser/lex-bad-char-literals-6.rs12
-rw-r--r--src/test/ui/parser/lex-bad-char-literals-6.stderr56
6 files changed, 91 insertions, 6 deletions
diff --git a/src/test/ui/parser/lex-bad-char-literals-2.rs b/src/test/ui/parser/lex-bad-char-literals-2.rs
index 7f859995218..1e180f87fc1 100644
--- a/src/test/ui/parser/lex-bad-char-literals-2.rs
+++ b/src/test/ui/parser/lex-bad-char-literals-2.rs
@@ -1,4 +1,4 @@
 // This test needs to the last one appearing in this file as it kills the parser
 static c: char =
-    'nope' //~ ERROR: character literal may only contain one codepoint: 'nope'
+    'nope' //~ ERROR: character literal may only contain one codepoint
 ;
diff --git a/src/test/ui/parser/lex-bad-char-literals-2.stderr b/src/test/ui/parser/lex-bad-char-literals-2.stderr
index a7075b71878..80999a4afcf 100644
--- a/src/test/ui/parser/lex-bad-char-literals-2.stderr
+++ b/src/test/ui/parser/lex-bad-char-literals-2.stderr
@@ -1,8 +1,13 @@
-error: character literal may only contain one codepoint: 'nope'
+error: character literal may only contain one codepoint
   --> $DIR/lex-bad-char-literals-2.rs:3:5
    |
 LL |     'nope' //~ ERROR: character literal may only contain one codepoint: 'nope'
    |     ^^^^^^
 
-error: aborting due to previous error
+error[E0601]: `main` function not found in crate `lex_bad_char_literals_2`
+   |
+   = note: consider adding a `main` function to `$DIR/lex-bad-char-literals-2.rs`
+
+error: aborting due to 2 previous errors
 
+For more information about this error, try `rustc --explain E0601`.
diff --git a/src/test/ui/parser/lex-bad-char-literals-4.rs b/src/test/ui/parser/lex-bad-char-literals-4.rs
index 966e2bb9496..e13f11f36df 100644
--- a/src/test/ui/parser/lex-bad-char-literals-4.rs
+++ b/src/test/ui/parser/lex-bad-char-literals-4.rs
@@ -1,5 +1,5 @@
 //
 // This test needs to the last one appearing in this file as it kills the parser
 static c: char =
-    '●  //~ ERROR: character literal may only contain one codepoint: '●
+    '●  //~ ERROR: character literal may only contain one codepoint
 ;
diff --git a/src/test/ui/parser/lex-bad-char-literals-4.stderr b/src/test/ui/parser/lex-bad-char-literals-4.stderr
index 550cb5449df..129f28aa3e8 100644
--- a/src/test/ui/parser/lex-bad-char-literals-4.stderr
+++ b/src/test/ui/parser/lex-bad-char-literals-4.stderr
@@ -1,8 +1,20 @@
-error: character literal may only contain one codepoint: '●
+error: character literal may only contain one codepoint
   --> $DIR/lex-bad-char-literals-4.rs:4:5
    |
 LL |     '●  //~ ERROR: character literal may only contain one codepoint: '●
    |     ^^
 
-error: aborting due to previous error
+error: character literal may only contain one codepoint
+  --> $DIR/lex-bad-char-literals-4.rs:4:70
+   |
+LL |     '●  //~ ERROR: character literal may only contain one codepoint: '●
+   |                                                                      ^^
+
+error: expected one of `.`, `;`, `?`, or an operator, found `~`
+  --> $DIR/lex-bad-char-literals-4.rs:4:11
+   |
+LL |     '●  //~ ERROR: character literal may only contain one codepoint: '●
+   |           ^ expected one of `.`, `;`, `?`, or an operator here
+
+error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/parser/lex-bad-char-literals-6.rs b/src/test/ui/parser/lex-bad-char-literals-6.rs
new file mode 100644
index 00000000000..8567a8680db
--- /dev/null
+++ b/src/test/ui/parser/lex-bad-char-literals-6.rs
@@ -0,0 +1,12 @@
+fn main() {
+    let x: &str = 'ab';  //~ ERROR: character literal may only contain one codepoint
+    //~^ ERROR: mismatched types
+    let y: char = 'cd';  //~ ERROR: character literal may only contain one codepoint
+    let z = 'ef';  //~ ERROR: character literal may only contain one codepoint
+
+    if x == y {}  //~ ERROR: can't compare `&str` with `char`
+    if y == z {}  // no error here
+    if x == z {}  //~ ERROR: can't compare `&str` with `char`
+
+    let a: usize = "";  //~ ERROR: mismatched types
+}
\ No newline at end of file
diff --git a/src/test/ui/parser/lex-bad-char-literals-6.stderr b/src/test/ui/parser/lex-bad-char-literals-6.stderr
new file mode 100644
index 00000000000..f1fcaaf687c
--- /dev/null
+++ b/src/test/ui/parser/lex-bad-char-literals-6.stderr
@@ -0,0 +1,56 @@
+error: character literal may only contain one codepoint
+  --> $DIR/lex-bad-char-literals-6.rs:2:19
+   |
+LL |     let x: &str = 'ab';  //~ ERROR: character literal may only contain one codepoint
+   |                   ^^^^
+
+error: character literal may only contain one codepoint
+  --> $DIR/lex-bad-char-literals-6.rs:3:19
+   |
+LL |     let y: char = 'cd';  //~ ERROR: character literal may only contain one codepoint
+   |                   ^^^^
+
+error: character literal may only contain one codepoint
+  --> $DIR/lex-bad-char-literals-6.rs:4:13
+   |
+LL |     let z = 'ef';  //~ ERROR: character literal may only contain one codepoint
+   |             ^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/lex-bad-char-literals-6.rs:2:19
+   |
+LL |     let x: &str = 'ab';  //~ ERROR: character literal may only contain one codepoint
+   |                   ^^^^ expected &str, found char
+   |
+   = note: expected type `&str`
+              found type `char`
+
+error[E0277]: can't compare `&str` with `char`
+  --> $DIR/lex-bad-char-literals-6.rs:6:10
+   |
+LL |     if x == y {}  // no error here
+   |          ^^ no implementation for `&str == char`
+   |
+   = help: the trait `std::cmp::PartialEq<char>` is not implemented for `&str`
+
+error[E0308]: mismatched types
+  --> $DIR/lex-bad-char-literals-6.rs:10:20
+   |
+LL |     let a: usize = "";  // type error here to confirm we got past the parser
+   |                    ^^ expected usize, found reference
+   |
+   = note: expected type `usize`
+              found type `&'static str`
+
+error[E0277]: can't compare `&str` with `char`
+  --> $DIR/lex-bad-char-literals-6.rs:8:10
+   |
+LL |     if x == z {}  // no error here
+   |          ^^ no implementation for `&str == char`
+   |
+   = help: the trait `std::cmp::PartialEq<char>` is not implemented for `&str`
+
+error: aborting due to 7 previous errors
+
+Some errors occurred: E0277, E0308.
+For more information about an error, try `rustc --explain E0277`.