Commit 192bb9c
authored
Rollup merge of #148510 - Zalathar:known-directives, r=jieyouxu
compiletest: Do the known-directives check only once, and improve its error message
This PR is a combination of three changes:
- Store the list of known directives in a set, so that checking a directive name doesn't require a linear scan
- Extract the known-directives check out of `iter_directives` and do it only once, instead of multiple times per file
- Improve the error message for unknown directives, [as requested on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Compiletest.20directive.20parsing.20error/with/553598083)
The change to error messages is fused with the extraction, since doing it independently would have been more awkward.
---
## Before
```text
Testing stage1 with compiletest suite=coverage mode=coverage-map (aarch64-apple-darwin)
errors encountered during EarlyProps parsing: /Users/stuart/Dev/rust/rust/tests/coverage/trivial.rs
2025-11-05T01:55:46.440012Z ERROR compiletest::directives: /Users/stuart/Dev/rust/rust/tests/coverage/trivial.rs:2: detected unknown compiletest test directive `add-core-stubs`
thread '<unnamed>' (36268582) panicked at src/tools/compiletest/src/directives.rs:72:13:
errors encountered during EarlyProps parsing
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
## After
```text
Testing stage1 with compiletest suite=coverage mode=coverage-map (aarch64-apple-darwin)
thread '<unnamed>' (36270772) panicked at src/tools/compiletest/src/lib.rs:876:9:
directives check failed:
ERROR: unknown compiletest directive `add-core-stubs` at /Users/stuart/Dev/rust/rust/tests/coverage/trivial.rs:2
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```File tree
4 files changed
+51
-61
lines changed- src/tools/compiletest/src
- directives
4 files changed
+51
-61
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | 56 | | |
58 | | - | |
59 | 57 | | |
60 | 58 | | |
61 | 59 | | |
62 | | - | |
63 | 60 | | |
64 | 61 | | |
65 | 62 | | |
66 | 63 | | |
67 | 64 | | |
68 | 65 | | |
69 | 66 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | 67 | | |
76 | 68 | | |
77 | 69 | | |
| |||
358 | 350 | | |
359 | 351 | | |
360 | 352 | | |
361 | | - | |
362 | | - | |
363 | 353 | | |
364 | 354 | | |
365 | | - | |
366 | 355 | | |
| 356 | + | |
367 | 357 | | |
368 | 358 | | |
369 | 359 | | |
| |||
634 | 624 | | |
635 | 625 | | |
636 | 626 | | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | | - | |
641 | | - | |
642 | 627 | | |
643 | 628 | | |
644 | 629 | | |
| |||
775 | 760 | | |
776 | 761 | | |
777 | 762 | | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
778 | 791 | | |
779 | 792 | | |
780 | 793 | | |
| |||
786 | 799 | | |
787 | 800 | | |
788 | 801 | | |
789 | | - | |
| 802 | + | |
790 | 803 | | |
791 | 804 | | |
792 | 805 | | |
| |||
799 | 812 | | |
800 | 813 | | |
801 | 814 | | |
802 | | - | |
| 815 | + | |
803 | 816 | | |
804 | 817 | | |
805 | 818 | | |
| |||
811 | 824 | | |
812 | 825 | | |
813 | 826 | | |
814 | | - | |
815 | 827 | | |
816 | 828 | | |
817 | 829 | | |
| |||
837 | 849 | | |
838 | 850 | | |
839 | 851 | | |
840 | | - | |
841 | | - | |
842 | | - | |
843 | | - | |
844 | | - | |
845 | | - | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
851 | | - | |
852 | | - | |
853 | | - | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | | - | |
858 | | - | |
859 | | - | |
860 | | - | |
861 | | - | |
862 | | - | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
| 852 | + | |
870 | 853 | | |
871 | 854 | | |
872 | 855 | | |
| |||
1304 | 1287 | | |
1305 | 1288 | | |
1306 | 1289 | | |
1307 | | - | |
1308 | | - | |
1309 | 1290 | | |
1310 | 1291 | | |
1311 | 1292 | | |
1312 | | - | |
1313 | 1293 | | |
1314 | 1294 | | |
1315 | 1295 | | |
| |||
1358 | 1338 | | |
1359 | 1339 | | |
1360 | 1340 | | |
1361 | | - | |
1362 | | - | |
1363 | | - | |
1364 | | - | |
1365 | | - | |
1366 | 1341 | | |
1367 | 1342 | | |
1368 | 1343 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
1 | 7 | | |
2 | 8 | | |
3 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
767 | 767 | | |
768 | 768 | | |
769 | 769 | | |
770 | | - | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
771 | 774 | | |
772 | 775 | | |
773 | 776 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
869 | 869 | | |
870 | 870 | | |
871 | 871 | | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
872 | 878 | | |
873 | 879 | | |
874 | 880 | | |
| |||
0 commit comments