11error: only `u8` can be cast into `char`
2-   --> $DIR/cast-char.rs:4:23 
2+   --> $DIR/cast-char.rs:12:31 
33   |
4- LL |     const XYZ : char = 0x1F888  as char;
5-    |                       ^^^^^^^^^^^^^^^  help: use a `char` literal instead: `'\u{1F888 }'`
4+ LL |     const VALID_LOW_1 : char = 0x1000  as char; // 4096 
5+    |                                ^^^^^^^^^^^^^^ help: use a `char` literal instead: `'\u{1000 }'`
66   |
77note: the lint level is defined here
88  --> $DIR/cast-char.rs:1:9
@@ -11,10 +11,120 @@ LL | #![deny(overflowing_literals)]
1111   |         ^^^^^^^^^^^^^^^^^^^^
1212
1313error: only `u8` can be cast into `char`
14-   --> $DIR/cast-char.rs:6:22 
14+   --> $DIR/cast-char.rs:14:31 
1515   |
16- LL |     const XY : char = 129160  as char;
17-    |                      ^^^^^^^^^^^^^^ help: use a `char` literal instead: `'\u{1F888 }'`
16+ LL |     const VALID_LOW_2 : char = 0xD7FF  as char; // last valid in lower range 
17+    |                                ^^^^^^^^^^^^^^ help: use a `char` literal instead: `'\u{D7FF }'`
1818
19- error: aborting due to 2 previous errors
19+ error: only `u8` can be cast into `char`
20+   --> $DIR/cast-char.rs:16:31
21+    |
22+ LL |     const VALID_LOW_3: char = 0x0500 as char; // cyrillic range
23+    |                               ^^^^^^^^^^^^^^ help: use a `char` literal instead: `'\u{500}'`
24+ 
25+ error: only `u8` can be cast into `char`
26+   --> $DIR/cast-char.rs:20:32
27+    |
28+ LL |     const VALID_HIGH_1: char = 0xE000 as char; // first valid in upper range
29+    |                                ^^^^^^^^^^^^^^ help: use a `char` literal instead: `'\u{E000}'`
30+ 
31+ error: only `u8` can be cast into `char`
32+   --> $DIR/cast-char.rs:22:32
33+    |
34+ LL |     const VALID_HIGH_2: char = 0x1F888 as char; // 129160 - example from issue
35+    |                                ^^^^^^^^^^^^^^^ help: use a `char` literal instead: `'\u{1F888}'`
36+ 
37+ error: only `u8` can be cast into `char`
38+   --> $DIR/cast-char.rs:24:32
39+    |
40+ LL |     const VALID_HIGH_3: char = 0x10FFFF as char; // maximum valid Unicode
41+    |                                ^^^^^^^^^^^^^^^^ help: use a `char` literal instead: `'\u{10FFFF}'`
42+ 
43+ error: only `u8` can be cast into `char`
44+   --> $DIR/cast-char.rs:26:32
45+    |
46+ LL |     const VALID_HIGH_4: char = 0xFFFD as char; // replacement character
47+    |                                ^^^^^^^^^^^^^^ help: use a `char` literal instead: `'\u{FFFD}'`
48+ 
49+ error: only `u8` can be cast into `char`
50+   --> $DIR/cast-char.rs:28:32
51+    |
52+ LL |     const VALID_HIGH_5: char = 0x1F600 as char; // emoji
53+    |                                ^^^^^^^^^^^^^^^ help: use a `char` literal instead: `'\u{1F600}'`
54+ 
55+ error: surrogate values are not valid for `char`
56+   --> $DIR/cast-char.rs:34:39
57+    |
58+ LL |     const INVALID_SURROGATE_1: char = 0xD800 as char; // first surrogate
59+    |                                       ^^^^^^^^^^^^^^
60+    |
61+    = note: `0xD800..=0xDFFF` are reserved for Unicode surrogates and are not valid `char` values
62+ 
63+ error: surrogate values are not valid for `char`
64+   --> $DIR/cast-char.rs:36:39
65+    |
66+ LL |     const INVALID_SURROGATE_2: char = 0xDFFF as char; // last surrogate
67+    |                                       ^^^^^^^^^^^^^^
68+    |
69+    = note: `0xD800..=0xDFFF` are reserved for Unicode surrogates and are not valid `char` values
70+ 
71+ error: surrogate values are not valid for `char`
72+   --> $DIR/cast-char.rs:38:39
73+    |
74+ LL |     const INVALID_SURROGATE_3: char = 0xDB00 as char; // middle of surrogate range
75+    |                                       ^^^^^^^^^^^^^^
76+    |
77+    = note: `0xD800..=0xDFFF` are reserved for Unicode surrogates and are not valid `char` values
78+ 
79+ error: value exceeds maximum `char` value
80+   --> $DIR/cast-char.rs:42:37
81+    |
82+ LL |     const INVALID_TOO_BIG_1: char = 0x110000 as char; // one more than maximum
83+    |                                     ^^^^^^^^^^^^^^^^
84+    |
85+    = note: maximum valid `char` value is `0x10FFFF`
86+ 
87+ error: value exceeds maximum `char` value
88+   --> $DIR/cast-char.rs:44:37
89+    |
90+ LL |     const INVALID_TOO_BIG_2: char = 0xEF8888 as char; // example from issue
91+    |                                     ^^^^^^^^^^^^^^^^
92+    |
93+    = note: maximum valid `char` value is `0x10FFFF`
94+ 
95+ error: value exceeds maximum `char` value
96+   --> $DIR/cast-char.rs:46:37
97+    |
98+ LL |     const INVALID_TOO_BIG_3: char = 0x1FFFFF as char; // much larger
99+    |                                     ^^^^^^^^^^^^^^^^
100+    |
101+    = note: maximum valid `char` value is `0x10FFFF`
102+ 
103+ error: value exceeds maximum `char` value
104+   --> $DIR/cast-char.rs:48:37
105+    |
106+ LL |     const INVALID_TOO_BIG_4: char = 0xFFFFFF as char; // 24-bit maximum
107+    |                                     ^^^^^^^^^^^^^^^^
108+    |
109+    = note: maximum valid `char` value is `0x10FFFF`
110+ 
111+ error: only `u8` can be cast into `char`
112+   --> $DIR/cast-char.rs:52:30
113+    |
114+ LL |     const BOUNDARY_1: char = 0xD7FE as char; // valid, before surrogate
115+    |                              ^^^^^^^^^^^^^^ help: use a `char` literal instead: `'\u{D7FE}'`
116+ 
117+ error: only `u8` can be cast into `char`
118+   --> $DIR/cast-char.rs:54:30
119+    |
120+ LL |     const BOUNDARY_2: char = 0xE001 as char; // valid, after surrogate
121+    |                              ^^^^^^^^^^^^^^ help: use a `char` literal instead: `'\u{E001}'`
122+ 
123+ error: only `u8` can be cast into `char`
124+   --> $DIR/cast-char.rs:56:30
125+    |
126+ LL |     const BOUNDARY_3: char = 0x10FFFE as char; // valid, near maximum
127+    |                              ^^^^^^^^^^^^^^^^ help: use a `char` literal instead: `'\u{10FFFE}'`
128+ 
129+ error: aborting due to 18 previous errors
20130
0 commit comments