Commit dc1feab
committed
Auto merge of rust-lang#147207 - Muscraft:anstyle-anstream, r=davidtwco
refactor: Move to anstream + anstyle for styling
`rustc` uses [`termcolor`](https://crates.io/crates/termcolor) for styling and writing, while `annotate-snippets` uses [`anstyle`](https://crates.io/crates/anstyle) for styling and currently writes directly to a `String`. When rendering directly to a terminal, there isn't/shouldn't be any differences. Still, there are differences in the escape sequences, which leads to slightly different output in JSON and SVG tests. As part of my work to have `rustc` use `annotate-snippets`, and to reduce the test differences between the two, I switched `rustc` to use `anstlye` and [`anstream`](https://crates.io/crates/anstream) for styling and writing.
The first commit migrates to `anstyle` and `anstream` and notably does not change the output. This is because it includes extra formatting to ensure that `anstyle` + `anstream` match the current output exactly. Most of this code is unnecessary, as it adds redundant resets or uses 256-color (8-bit) when it could be using 4-bit color. The subsequent commits remove this extra formatting while maintaining the correct output when rendered.
[Zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/147480-t-compiler.2Fdiagnostics/topic/annotate-snippets.20hurdles)File tree
30 files changed
+1234
-1266
lines changed- compiler
- rustc_driver_impl/src
- rustc_errors
- src
- markdown
- tests
- rustc_parse
- src/parser
- src
- librustdoc/doctest
- tools
- clippy/clippy_lints/src/doc
- tidy/src
- tests/ui
- argument-suggestions
- codemap_tests
- diagnostic-flags
- error-emitter
- impl-trait/diagnostics
- lint
- suggestions
30 files changed
+1234
-1266
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
3757 | 3757 | | |
3758 | 3758 | | |
3759 | 3759 | | |
| 3760 | + | |
| 3761 | + | |
3760 | 3762 | | |
3761 | 3763 | | |
3762 | 3764 | | |
| |||
3773 | 3775 | | |
3774 | 3776 | | |
3775 | 3777 | | |
3776 | | - | |
3777 | 3778 | | |
3778 | 3779 | | |
3779 | 3780 | | |
| |||
4327 | 4328 | | |
4328 | 4329 | | |
4329 | 4330 | | |
4330 | | - | |
4331 | 4331 | | |
4332 | 4332 | | |
4333 | 4333 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
520 | 520 | | |
521 | 521 | | |
522 | 522 | | |
523 | | - | |
| 523 | + | |
524 | 524 | | |
525 | 525 | | |
526 | | - | |
527 | | - | |
| 526 | + | |
| 527 | + | |
528 | 528 | | |
529 | 529 | | |
530 | 530 | | |
| |||
545 | 545 | | |
546 | 546 | | |
547 | 547 | | |
548 | | - | |
549 | | - | |
| 548 | + | |
| 549 | + | |
550 | 550 | | |
551 | 551 | | |
552 | 552 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | | - | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
28 | | - | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
525 | 526 | | |
526 | 527 | | |
527 | 528 | | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | 529 | | |
533 | 530 | | |
534 | 531 | | |
| |||
1701 | 1698 | | |
1702 | 1699 | | |
1703 | 1700 | | |
1704 | | - | |
1705 | 1701 | | |
1706 | 1702 | | |
1707 | 1703 | | |
| |||
3127 | 3123 | | |
3128 | 3124 | | |
3129 | 3125 | | |
3130 | | - | |
3131 | 3126 | | |
3132 | 3127 | | |
3133 | 3128 | | |
| |||
3361 | 3356 | | |
3362 | 3357 | | |
3363 | 3358 | | |
3364 | | - | |
| 3359 | + | |
3365 | 3360 | | |
3366 | 3361 | | |
3367 | 3362 | | |
| |||
3406 | 3401 | | |
3407 | 3402 | | |
3408 | 3403 | | |
3409 | | - | |
| 3404 | + | |
3410 | 3405 | | |
3411 | 3406 | | |
3412 | 3407 | | |
| |||
3429 | 3424 | | |
3430 | 3425 | | |
3431 | 3426 | | |
3432 | | - | |
3433 | | - | |
3434 | | - | |
3435 | | - | |
| 3427 | + | |
| 3428 | + | |
3436 | 3429 | | |
3437 | 3430 | | |
3438 | 3431 | | |
| |||
3442 | 3435 | | |
3443 | 3436 | | |
3444 | 3437 | | |
3445 | | - | |
| 3438 | + | |
3446 | 3439 | | |
3447 | 3440 | | |
3448 | | - | |
3449 | | - | |
| 3441 | + | |
| 3442 | + | |
3450 | 3443 | | |
3451 | 3444 | | |
3452 | 3445 | | |
| |||
3455 | 3448 | | |
3456 | 3449 | | |
3457 | 3450 | | |
3458 | | - | |
| 3451 | + | |
3459 | 3452 | | |
3460 | 3453 | | |
3461 | 3454 | | |
| |||
3470 | 3463 | | |
3471 | 3464 | | |
3472 | 3465 | | |
3473 | | - | |
3474 | | - | |
3475 | | - | |
3476 | | - | |
3477 | | - | |
3478 | | - | |
3479 | | - | |
3480 | | - | |
3481 | | - | |
3482 | | - | |
3483 | | - | |
3484 | | - | |
3485 | | - | |
3486 | | - | |
3487 | 3466 | | |
| 3467 | + | |
3488 | 3468 | | |
| 3469 | + | |
| 3470 | + | |
| 3471 | + | |
| 3472 | + | |
| 3473 | + | |
| 3474 | + | |
| 3475 | + | |
3489 | 3476 | | |
3490 | 3477 | | |
3491 | 3478 | | |
3492 | 3479 | | |
3493 | 3480 | | |
3494 | 3481 | | |
3495 | 3482 | | |
3496 | | - | |
| 3483 | + | |
3497 | 3484 | | |
3498 | | - | |
3499 | | - | |
3500 | | - | |
| 3485 | + | |
| 3486 | + | |
3501 | 3487 | | |
3502 | 3488 | | |
3503 | 3489 | | |
3504 | 3490 | | |
3505 | 3491 | | |
3506 | 3492 | | |
3507 | | - | |
| 3493 | + | |
| 3494 | + | |
| 3495 | + | |
| 3496 | + | |
| 3497 | + | |
3508 | 3498 | | |
3509 | 3499 | | |
3510 | | - | |
3511 | | - | |
| 3500 | + | |
3512 | 3501 | | |
3513 | | - | |
3514 | | - | |
3515 | | - | |
3516 | | - | |
3517 | | - | |
3518 | | - | |
3519 | | - | |
3520 | | - | |
3521 | | - | |
3522 | | - | |
3523 | | - | |
3524 | | - | |
3525 | | - | |
3526 | | - | |
3527 | | - | |
3528 | | - | |
3529 | | - | |
3530 | | - | |
3531 | | - | |
3532 | | - | |
3533 | | - | |
3534 | | - | |
3535 | | - | |
3536 | | - | |
3537 | | - | |
3538 | | - | |
3539 | | - | |
3540 | | - | |
3541 | | - | |
3542 | | - | |
3543 | | - | |
3544 | | - | |
3545 | | - | |
3546 | | - | |
| 3502 | + | |
| 3503 | + | |
| 3504 | + | |
| 3505 | + | |
| 3506 | + | |
| 3507 | + | |
| 3508 | + | |
| 3509 | + | |
| 3510 | + | |
3547 | 3511 | | |
| 3512 | + | |
| 3513 | + | |
| 3514 | + | |
| 3515 | + | |
| 3516 | + | |
| 3517 | + | |
3548 | 3518 | | |
3549 | | - | |
3550 | 3519 | | |
3551 | 3520 | | |
3552 | 3521 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | | - | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
336 | | - | |
| 336 | + | |
337 | 337 | | |
338 | 338 | | |
339 | 339 | | |
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | 347 | | |
361 | 348 | | |
362 | 349 | | |
| |||
382 | 369 | | |
383 | 370 | | |
384 | 371 | | |
385 | | - | |
386 | | - | |
| 372 | + | |
387 | 373 | | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
392 | 381 | | |
393 | 382 | | |
394 | 383 | | |
| |||
0 commit comments