Commit 6afcb56
committed
Auto merge of rust-lang#60065 - QuietMisdreavus:async-move-doctests, r=ollie27
rustdoc: set the default edition when pre-parsing a doctest
Fixes rust-lang#59313 (possibly more? i think we've had issues with parsing edition-specific syntax in doctests at some point)
When handling a doctest, rustdoc needs to parse it beforehand, so that it can see whether it declares a `fn main` or `extern crate my_crate` explicitly. However, while doing this, rustdoc doesn't set the "default edition" used by the parser like the regular compilation runs do. This caused a problem when parsing a doctest with an `async move` block in it, since it was expecting the `move` keyword to start a closure, not a block.
This PR changes the `rustdoc::test::make_test` function to set the parser's default edition while looking for a main function and `extern crate` statement. However, to do this, `make_test` needs to know what edition to set. Since this is also used during the HTML rendering process (to make playground URLs), now the HTML renderer needs to know about the default edition. Upshot: rendering standalone markdown files can now accept a "default edition" for their doctests with the `--edition` flag! (I'm pretty sure i waffled around how to set that a long time ago when we first added the `--edition` flag... `>_>`)
I'm posting this before i stop for the night so that i can write this description while it's still in my head, but before this merges i want to make sure that (1) the `rustdoc-ui/failed-doctest-output` test still works (i expect it doesn't), and (2) i add a test with the sample from the linked issue.File tree
11 files changed
+136
-80
lines changed- src
- librustdoc
- html
- test/rustdoc
- tools/error_index_generator
11 files changed
+136
-80
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
389 | 401 | | |
390 | 402 | | |
391 | 403 | | |
392 | 404 | | |
393 | 405 | | |
394 | 406 | | |
395 | 407 | | |
396 | | - | |
| 408 | + | |
| 409 | + | |
397 | 410 | | |
398 | 411 | | |
399 | 412 | | |
400 | 413 | | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | 414 | | |
411 | 415 | | |
412 | 416 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | | - | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | | - | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
46 | | - | |
| 48 | + | |
| 49 | + | |
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
16 | | - | |
| 19 | + | |
| 20 | + | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| |||
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
45 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
46 | 57 | | |
47 | | - | |
| 58 | + | |
48 | 59 | | |
49 | 60 | | |
50 | | - | |
| 61 | + | |
51 | 62 | | |
52 | | - | |
| 63 | + | |
53 | 64 | | |
54 | 65 | | |
55 | 66 | | |
| |||
146 | 157 | | |
147 | 158 | | |
148 | 159 | | |
| 160 | + | |
149 | 161 | | |
150 | 162 | | |
151 | 163 | | |
152 | | - | |
| 164 | + | |
153 | 165 | | |
154 | 166 | | |
155 | 167 | | |
| 168 | + | |
156 | 169 | | |
157 | 170 | | |
158 | 171 | | |
| |||
177 | 190 | | |
178 | 191 | | |
179 | 192 | | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
180 | 196 | | |
181 | 197 | | |
182 | 198 | | |
| |||
202 | 218 | | |
203 | 219 | | |
204 | 220 | | |
205 | | - | |
| 221 | + | |
206 | 222 | | |
207 | 223 | | |
208 | 224 | | |
209 | 225 | | |
210 | 226 | | |
211 | 227 | | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
| 228 | + | |
221 | 229 | | |
222 | 230 | | |
223 | 231 | | |
| |||
247 | 255 | | |
248 | 256 | | |
249 | 257 | | |
250 | | - | |
251 | | - | |
| 258 | + | |
| 259 | + | |
252 | 260 | | |
253 | 261 | | |
254 | 262 | | |
| |||
259 | 267 | | |
260 | 268 | | |
261 | 269 | | |
262 | | - | |
| 270 | + | |
263 | 271 | | |
264 | 272 | | |
265 | 273 | | |
| |||
270 | 278 | | |
271 | 279 | | |
272 | 280 | | |
273 | | - | |
| 281 | + | |
274 | 282 | | |
275 | 283 | | |
276 | 284 | | |
| |||
659 | 667 | | |
660 | 668 | | |
661 | 669 | | |
662 | | - | |
| 670 | + | |
663 | 671 | | |
664 | 672 | | |
665 | 673 | | |
| |||
678 | 686 | | |
679 | 687 | | |
680 | 688 | | |
681 | | - | |
| 689 | + | |
682 | 690 | | |
683 | 691 | | |
684 | 692 | | |
| |||
688 | 696 | | |
689 | 697 | | |
690 | 698 | | |
691 | | - | |
| 699 | + | |
692 | 700 | | |
693 | 701 | | |
694 | 702 | | |
| |||
699 | 707 | | |
700 | 708 | | |
701 | 709 | | |
702 | | - | |
| 710 | + | |
703 | 711 | | |
704 | 712 | | |
705 | 713 | | |
| |||
712 | 720 | | |
713 | 721 | | |
714 | 722 | | |
715 | | - | |
| 723 | + | |
716 | 724 | | |
717 | 725 | | |
718 | 726 | | |
| |||
728 | 736 | | |
729 | 737 | | |
730 | 738 | | |
731 | | - | |
| 739 | + | |
732 | 740 | | |
733 | 741 | | |
734 | 742 | | |
| |||
1046 | 1054 | | |
1047 | 1055 | | |
1048 | 1056 | | |
1049 | | - | |
| 1057 | + | |
1050 | 1058 | | |
1051 | 1059 | | |
1052 | 1060 | | |
| |||
1098 | 1106 | | |
1099 | 1107 | | |
1100 | 1108 | | |
1101 | | - | |
| 1109 | + | |
| 1110 | + | |
1102 | 1111 | | |
1103 | 1112 | | |
1104 | 1113 | | |
| |||
1120 | 1129 | | |
1121 | 1130 | | |
1122 | 1131 | | |
1123 | | - | |
| 1132 | + | |
| 1133 | + | |
1124 | 1134 | | |
1125 | 1135 | | |
1126 | 1136 | | |
| |||
1157 | 1167 | | |
1158 | 1168 | | |
1159 | 1169 | | |
1160 | | - | |
| 1170 | + | |
| 1171 | + | |
1161 | 1172 | | |
1162 | 1173 | | |
1163 | 1174 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
| 112 | + | |
| 113 | + | |
111 | 114 | | |
112 | 115 | | |
113 | 116 | | |
| |||
514 | 517 | | |
515 | 518 | | |
516 | 519 | | |
517 | | - | |
| 520 | + | |
| 521 | + | |
518 | 522 | | |
519 | 523 | | |
520 | 524 | | |
| |||
604 | 608 | | |
605 | 609 | | |
606 | 610 | | |
| 611 | + | |
607 | 612 | | |
608 | 613 | | |
609 | 614 | | |
| |||
1128 | 1133 | | |
1129 | 1134 | | |
1130 | 1135 | | |
1131 | | - | |
| 1136 | + | |
1132 | 1137 | | |
1133 | 1138 | | |
1134 | 1139 | | |
| |||
2553 | 2558 | | |
2554 | 2559 | | |
2555 | 2560 | | |
2556 | | - | |
| 2561 | + | |
2557 | 2562 | | |
2558 | 2563 | | |
2559 | 2564 | | |
| |||
2918 | 2923 | | |
2919 | 2924 | | |
2920 | 2925 | | |
2921 | | - | |
| 2926 | + | |
2922 | 2927 | | |
2923 | 2928 | | |
2924 | 2929 | | |
| |||
2967 | 2972 | | |
2968 | 2973 | | |
2969 | 2974 | | |
2970 | | - | |
| 2975 | + | |
2971 | 2976 | | |
2972 | 2977 | | |
2973 | 2978 | | |
| |||
4197 | 4202 | | |
4198 | 4203 | | |
4199 | 4204 | | |
4200 | | - | |
| 4205 | + | |
| 4206 | + | |
4201 | 4207 | | |
4202 | 4208 | | |
4203 | 4209 | | |
| |||
0 commit comments