Skip to content

Commit 8762485

Browse files
committed
Update UI tests
1 parent ed40d46 commit 8762485

6 files changed

+45
-4
lines changed

src/test/ui/inference/char-as-str-single.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
fn main() {
99
let _: char = 'a'; //~ ERROR mismatched types
1010
let _: char = '人'; //~ ERROR mismatched types
11+
let _: char = '\''; //~ ERROR mismatched types
1112
}

src/test/ui/inference/char-as-str-single.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
fn main() {
99
let _: char = "a"; //~ ERROR mismatched types
1010
let _: char = "人"; //~ ERROR mismatched types
11+
let _: char = "'"; //~ ERROR mismatched types
1112
}

src/test/ui/inference/char-as-str-single.stderr

+14-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ help: if you meant to write a `char` literal, use single quotes
2424
LL | let _: char = '人';
2525
| ~~~~
2626

27-
error: aborting due to 2 previous errors
27+
error[E0308]: mismatched types
28+
--> $DIR/char-as-str-single.rs:11:19
29+
|
30+
LL | let _: char = "'";
31+
| ---- ^^^ expected `char`, found `&str`
32+
| |
33+
| expected due to this
34+
|
35+
help: if you meant to write a `char` literal, use single quotes
36+
|
37+
LL | let _: char = '\'';
38+
| ~~~~
39+
40+
error: aborting due to 3 previous errors
2841

2942
For more information about this error, try `rustc --explain E0308`.

src/test/ui/inference/str-as-char.fixed

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
// run-rustfix
55

66
fn main() {
7-
let _: &str = "a"; //~ ERROR mismatched types
7+
let _: &str = "a"; //~ ERROR mismatched types
8+
let _: &str = "\"\"\""; //~ ERROR character literal may only contain one codepoint
9+
let _: &str = "\"\"\""; //~ ERROR character literal may only contain one codepoint
810
}

src/test/ui/inference/str-as-char.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
// run-rustfix
55

66
fn main() {
7-
let _: &str = 'a'; //~ ERROR mismatched types
7+
let _: &str = 'a'; //~ ERROR mismatched types
8+
let _: &str = '"""'; //~ ERROR character literal may only contain one codepoint
9+
let _: &str = '\"\"\"'; //~ ERROR character literal may only contain one codepoint
810
}

src/test/ui/inference/str-as-char.stderr

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
error: character literal may only contain one codepoint
2+
--> $DIR/str-as-char.rs:8:19
3+
|
4+
LL | let _: &str = '"""';
5+
| ^^^^^
6+
|
7+
help: if you meant to write a `str` literal, use double quotes
8+
|
9+
LL | let _: &str = "\"\"\"";
10+
| ~~~~~~~~
11+
12+
error: character literal may only contain one codepoint
13+
--> $DIR/str-as-char.rs:9:19
14+
|
15+
LL | let _: &str = '\"\"\"';
16+
| ^^^^^^^^
17+
|
18+
help: if you meant to write a `str` literal, use double quotes
19+
|
20+
LL | let _: &str = "\"\"\"";
21+
| ~~~~~~~~
22+
123
error[E0308]: mismatched types
224
--> $DIR/str-as-char.rs:7:19
325
|
@@ -11,6 +33,6 @@ help: if you meant to write a `str` literal, use double quotes
1133
LL | let _: &str = "a";
1234
| ~~~
1335

14-
error: aborting due to previous error
36+
error: aborting due to 3 previous errors
1537

1638
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)