Skip to content

Commit e9af312

Browse files
committed
[WIP] Fix tests
1 parent c502a79 commit e9af312

6 files changed

+91
-6
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// This test needs to the last one appearing in this file as it kills the parser
22
static c: char =
3-
'nope' //~ ERROR: character literal may only contain one codepoint: 'nope'
3+
'nope' //~ ERROR: character literal may only contain one codepoint
44
;
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
error: character literal may only contain one codepoint: 'nope'
1+
error: character literal may only contain one codepoint
22
--> $DIR/lex-bad-char-literals-2.rs:3:5
33
|
44
LL | 'nope' //~ ERROR: character literal may only contain one codepoint: 'nope'
55
| ^^^^^^
66

7-
error: aborting due to previous error
7+
error[E0601]: `main` function not found in crate `lex_bad_char_literals_2`
8+
|
9+
= note: consider adding a `main` function to `$DIR/lex-bad-char-literals-2.rs`
10+
11+
error: aborting due to 2 previous errors
812

13+
For more information about this error, try `rustc --explain E0601`.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
22
// This test needs to the last one appearing in this file as it kills the parser
33
static c: char =
4-
'//~ ERROR: character literal may only contain one codepoint: '●
4+
'//~ ERROR: character literal may only contain one codepoint
55
;
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
error: character literal may only contain one codepoint: '●
1+
error: character literal may only contain one codepoint
22
--> $DIR/lex-bad-char-literals-4.rs:4:5
33
|
44
LL | '● //~ ERROR: character literal may only contain one codepoint: '●
55
| ^^
66

7-
error: aborting due to previous error
7+
error: character literal may only contain one codepoint
8+
--> $DIR/lex-bad-char-literals-4.rs:4:70
9+
|
10+
LL | '● //~ ERROR: character literal may only contain one codepoint: '●
11+
| ^^
12+
13+
error: expected one of `.`, `;`, `?`, or an operator, found `~`
14+
--> $DIR/lex-bad-char-literals-4.rs:4:11
15+
|
16+
LL | '● //~ ERROR: character literal may only contain one codepoint: '●
17+
| ^ expected one of `.`, `;`, `?`, or an operator here
18+
19+
error: aborting due to 3 previous errors
820

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fn main() {
2+
let x: &str = 'ab'; //~ ERROR: character literal may only contain one codepoint
3+
//~^ ERROR: mismatched types
4+
let y: char = 'cd'; //~ ERROR: character literal may only contain one codepoint
5+
let z = 'ef'; //~ ERROR: character literal may only contain one codepoint
6+
7+
if x == y {} //~ ERROR: can't compare `&str` with `char`
8+
if y == z {} // no error here
9+
if x == z {} //~ ERROR: can't compare `&str` with `char`
10+
11+
let a: usize = ""; //~ ERROR: mismatched types
12+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
error: character literal may only contain one codepoint
2+
--> $DIR/lex-bad-char-literals-6.rs:2:19
3+
|
4+
LL | let x: &str = 'ab'; //~ ERROR: character literal may only contain one codepoint
5+
| ^^^^
6+
7+
error: character literal may only contain one codepoint
8+
--> $DIR/lex-bad-char-literals-6.rs:3:19
9+
|
10+
LL | let y: char = 'cd'; //~ ERROR: character literal may only contain one codepoint
11+
| ^^^^
12+
13+
error: character literal may only contain one codepoint
14+
--> $DIR/lex-bad-char-literals-6.rs:4:13
15+
|
16+
LL | let z = 'ef'; //~ ERROR: character literal may only contain one codepoint
17+
| ^^^^
18+
19+
error[E0308]: mismatched types
20+
--> $DIR/lex-bad-char-literals-6.rs:2:19
21+
|
22+
LL | let x: &str = 'ab'; //~ ERROR: character literal may only contain one codepoint
23+
| ^^^^ expected &str, found char
24+
|
25+
= note: expected type `&str`
26+
found type `char`
27+
28+
error[E0277]: can't compare `&str` with `char`
29+
--> $DIR/lex-bad-char-literals-6.rs:6:10
30+
|
31+
LL | if x == y {} // no error here
32+
| ^^ no implementation for `&str == char`
33+
|
34+
= help: the trait `std::cmp::PartialEq<char>` is not implemented for `&str`
35+
36+
error[E0308]: mismatched types
37+
--> $DIR/lex-bad-char-literals-6.rs:10:20
38+
|
39+
LL | let a: usize = ""; // type error here to confirm we got past the parser
40+
| ^^ expected usize, found reference
41+
|
42+
= note: expected type `usize`
43+
found type `&'static str`
44+
45+
error[E0277]: can't compare `&str` with `char`
46+
--> $DIR/lex-bad-char-literals-6.rs:8:10
47+
|
48+
LL | if x == z {} // no error here
49+
| ^^ no implementation for `&str == char`
50+
|
51+
= help: the trait `std::cmp::PartialEq<char>` is not implemented for `&str`
52+
53+
error: aborting due to 7 previous errors
54+
55+
Some errors occurred: E0277, E0308.
56+
For more information about an error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)