Commit f2dee33
committed
Implement RFC 3349, mixed utf8 literals.
Specifically:
- Allow unicode chars in b"" and br"" literals. This is done by changing
`Mode::allow_unicode_chars` to succeed on `ByteStr` and `RawByteStr`.
- Allow unicode escapes in b"" literals. This is done by changing
`Mode::allow_unicode_escapes` to succeed on `ByteStr`.
Byte string literals can already have high bytes (`\x80`..`\xff`).
Because they now also support unicode chars, they can now be mixed utf8,
so we use `unescape_mixed`/`cook_mixed` instead of
`unescape_unicode`/`cook_unicode` to process them.
A new type `Rfc3349`, is used to implement the feature gating. Values of
that type are threaded through the unescaping code to track whether
rules from rfc3349 are required for unescaping to succeed.
Test changes
XXX: not sure about the latter three; could just move them into
accepting tests
- tests/ui/attributes/key-value-non-ascii.rs: changed from a byte string
literal to a byte literal; we just need some kind of problem with a
literal to preserve the test's intent.
- tests/ui/parser/raw/raw-byte-string-literals.rs: removed the raw byte
string literal with a non-ASCII char. The other lexing errors meant
that the feature gate warning wasn't occurring anyway, because
compilation was aborting too early. No great loss, because we'll test
far more complex cases in `tests/ui/mixed-utf8-literals/`.
- tests/ui/parser/byte-string-literals.rs: similar.
- tests/ui/parser/issues/issue-23620-invalid-escapes.rs: left the test
unchanged; two old `unicode escape in byte string` errors are now
`mixed utf8 b"" and br"" literals are experimental` errors.
- tests/ui/parser/unicode-control-codepoints.rs: similar.
- tests/ui/suggestions/multibyte-escapes.rs: similar.
XXX: not sure how to handle rust-analyzer, just allowed mixed utf8
literals everywhere without complaint1 parent 6077f82 commit f2dee33
File tree
29 files changed
+306
-226
lines changed- compiler
- rustc_ast_passes/src
- rustc_ast/src/util
- rustc_feature/src
- rustc_lexer/src
- unescape
- rustc_parse_format/src
- rustc_parse
- src/lexer
- rustc_span/src
- src
- doc/unstable-book/src/language-features
- tools
- clippy/clippy_dev/src
- rust-analyzer/crates
- parser/src
- syntax/src
- ast
- tests/ui
- attributes
- feature-gates
- parser
- issues
- raw
- suggestions
29 files changed
+306
-226
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
87 | | - | |
| 88 | + | |
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| |||
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
111 | | - | |
112 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
113 | 117 | | |
114 | 118 | | |
115 | 119 | | |
| |||
125 | 129 | | |
126 | 130 | | |
127 | 131 | | |
128 | | - | |
| 132 | + | |
129 | 133 | | |
130 | 134 | | |
131 | 135 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
508 | 508 | | |
509 | 509 | | |
510 | 510 | | |
| 511 | + | |
511 | 512 | | |
512 | 513 | | |
513 | 514 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
520 | 520 | | |
521 | 521 | | |
522 | 522 | | |
| 523 | + | |
| 524 | + | |
523 | 525 | | |
524 | 526 | | |
525 | 527 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| |||
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
88 | | - | |
| 91 | + | |
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
| |||
94 | 97 | | |
95 | 98 | | |
96 | 99 | | |
| 100 | + | |
97 | 101 | | |
98 | | - | |
| 102 | + | |
99 | 103 | | |
100 | 104 | | |
101 | 105 | | |
102 | 106 | | |
103 | 107 | | |
104 | 108 | | |
105 | 109 | | |
106 | | - | |
| 110 | + | |
107 | 111 | | |
108 | 112 | | |
109 | 113 | | |
| |||
142 | 146 | | |
143 | 147 | | |
144 | 148 | | |
145 | | - | |
| 149 | + | |
146 | 150 | | |
147 | 151 | | |
148 | 152 | | |
149 | 153 | | |
| 154 | + | |
150 | 155 | | |
151 | 156 | | |
152 | 157 | | |
153 | 158 | | |
154 | 159 | | |
155 | 160 | | |
156 | | - | |
| 161 | + | |
157 | 162 | | |
158 | 163 | | |
159 | 164 | | |
| |||
169 | 174 | | |
170 | 175 | | |
171 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
172 | 186 | | |
173 | 187 | | |
174 | 188 | | |
| |||
205 | 219 | | |
206 | 220 | | |
207 | 221 | | |
208 | | - | |
| 222 | + | |
209 | 223 | | |
210 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
211 | 229 | | |
212 | 230 | | |
213 | 231 | | |
214 | 232 | | |
215 | 233 | | |
216 | | - | |
| 234 | + | |
217 | 235 | | |
218 | | - | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
219 | 241 | | |
220 | 242 | | |
221 | 243 | | |
| |||
233 | 255 | | |
234 | 256 | | |
235 | 257 | | |
| 258 | + | |
236 | 259 | | |
237 | 260 | | |
238 | 261 | | |
| |||
262 | 285 | | |
263 | 286 | | |
264 | 287 | | |
265 | | - | |
| 288 | + | |
266 | 289 | | |
267 | 290 | | |
268 | 291 | | |
269 | 292 | | |
270 | 293 | | |
271 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
272 | 299 | | |
273 | 300 | | |
274 | 301 | | |
| |||
296 | 323 | | |
297 | 324 | | |
298 | 325 | | |
299 | | - | |
| 326 | + | |
300 | 327 | | |
301 | 328 | | |
302 | 329 | | |
| |||
322 | 349 | | |
323 | 350 | | |
324 | 351 | | |
325 | | - | |
326 | | - | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
327 | 359 | | |
328 | 360 | | |
329 | 361 | | |
330 | 362 | | |
| 363 | + | |
331 | 364 | | |
332 | | - | |
| 365 | + | |
333 | 366 | | |
334 | 367 | | |
335 | | - | |
| 368 | + | |
336 | 369 | | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
337 | 374 | | |
338 | 375 | | |
339 | 376 | | |
| |||
342 | 379 | | |
343 | 380 | | |
344 | 381 | | |
345 | | - | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
346 | 387 | | |
347 | 388 | | |
348 | 389 | | |
349 | 390 | | |
350 | | - | |
| 391 | + | |
351 | 392 | | |
352 | 393 | | |
353 | 394 | | |
| |||
367 | 408 | | |
368 | 409 | | |
369 | 410 | | |
370 | | - | |
| 411 | + | |
371 | 412 | | |
372 | 413 | | |
373 | 414 | | |
374 | 415 | | |
375 | | - | |
| 416 | + | |
376 | 417 | | |
377 | 418 | | |
378 | 419 | | |
379 | 420 | | |
| 421 | + | |
380 | 422 | | |
381 | 423 | | |
382 | 424 | | |
| |||
409 | 451 | | |
410 | 452 | | |
411 | 453 | | |
412 | | - | |
| 454 | + | |
413 | 455 | | |
414 | 456 | | |
415 | 457 | | |
416 | 458 | | |
417 | | - | |
| 459 | + | |
418 | 460 | | |
419 | 461 | | |
420 | 462 | | |
| |||
423 | 465 | | |
424 | 466 | | |
425 | 467 | | |
426 | | - | |
| 468 | + | |
427 | 469 | | |
428 | 470 | | |
429 | 471 | | |
430 | 472 | | |
| 473 | + | |
431 | 474 | | |
432 | 475 | | |
433 | 476 | | |
434 | | - | |
| 477 | + | |
435 | 478 | | |
436 | | - | |
| 479 | + | |
437 | 480 | | |
438 | 481 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
| |||
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
127 | | - | |
| 129 | + | |
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
131 | 133 | | |
132 | 134 | | |
133 | 135 | | |
134 | 136 | | |
| 137 | + | |
135 | 138 | | |
136 | 139 | | |
137 | 140 | | |
| |||
240 | 243 | | |
241 | 244 | | |
242 | 245 | | |
243 | | - | |
244 | | - | |
245 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
246 | 249 | | |
247 | | - | |
248 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
249 | 255 | | |
250 | 256 | | |
251 | 257 | | |
252 | | - | |
| 258 | + | |
| 259 | + | |
253 | 260 | | |
254 | 261 | | |
255 | 262 | | |
| |||
264 | 271 | | |
265 | 272 | | |
266 | 273 | | |
267 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
268 | 277 | | |
269 | 278 | | |
270 | 279 | | |
| |||
276 | 285 | | |
277 | 286 | | |
278 | 287 | | |
279 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
280 | 292 | | |
281 | 293 | | |
282 | 294 | | |
| |||
0 commit comments