Commit 32a6a95
authored
Rollup merge of rust-lang#56793 - QuietMisdreavus:better-doctests, r=GuillaumeGomez
rustdoc: look for comments when scraping attributes/crates from doctests
Fixes rust-lang#56727
When scraping out crate-level attributes and `extern crate` statements, we wouldn't look for comments, so any presence of comments would shunt it and everything after it into "everything else". This could cause parsing issues when looking for `fn main` and `extern crate my_crate` later on, which would in turn cause rustdoc to incorrectly wrap a test with `fn main` when it already had one declared.
I took the opportunity to clean up the logic a little bit, but it would still benefit from a libsyntax-based loop like the `fn main` detection.2 files changed
+88
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
| 398 | + | |
398 | 399 | | |
399 | 400 | | |
400 | 401 | | |
| |||
488 | 489 | | |
489 | 490 | | |
490 | 491 | | |
| 492 | + | |
| 493 | + | |
491 | 494 | | |
492 | 495 | | |
493 | 496 | | |
494 | 497 | | |
495 | 498 | | |
496 | | - | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
497 | 506 | | |
498 | 507 | | |
499 | 508 | | |
500 | 509 | | |
501 | 510 | | |
502 | 511 | | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
514 | 550 | | |
515 | 551 | | |
516 | 552 | | |
517 | | - | |
518 | | - | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
519 | 557 | | |
520 | 558 | | |
521 | 559 | | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
522 | 564 | | |
523 | 565 | | |
524 | 566 | | |
| |||
1035 | 1077 | | |
1036 | 1078 | | |
1037 | 1079 | | |
1038 | | - | |
1039 | 1080 | | |
| 1081 | + | |
1040 | 1082 | | |
1041 | 1083 | | |
1042 | 1084 | | |
| |||
1083 | 1125 | | |
1084 | 1126 | | |
1085 | 1127 | | |
1086 | | - | |
1087 | 1128 | | |
| 1129 | + | |
1088 | 1130 | | |
1089 | 1131 | | |
1090 | 1132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
0 commit comments