Commit b864d23
authored
Rollup merge of rust-lang#69194 - Centril:assoc-extern-fuse, r=petrochenkov
parse: fuse associated and extern items up to defaultness
Language changes:
- The grammar of extern `type` aliases is unified with associated ones, and becomes:
```rust
TypeItem = "type" ident generics {":" bounds}? where_clause {"=" type}? ";" ;
```
Semantic restrictions (`ast_validation`) are added to forbid any parameters in `generics`, any bounds in `bounds`, and any predicates in `where_clause`, as well as the presence of a type expression (`= u8`).
(Work still remains to fuse this with free `type` aliases, but this can be done later.)
- The grammar of constants and static items (free, associated, and extern) now permits the absence of an expression, and becomes:
```rust
GlobalItem = {"const" {ident | "_"} | "static" "mut"? ident} {"=" expr}? ";" ;
```
- A semantic restriction is added to enforce the presence of the expression (the body).
- A semantic restriction is added to reject `const _` in associated contexts.
Together, these changes allow us to fuse the grammar of associated items and extern items up to `default`ness which is the main goal of the PR.
-----------------------
We are now very close to fully fusing the entirely of item parsing and their ASTs. To progress further, we must make a decision: should we parse e.g. `default use foo::bar;` and whatnot? Accepting that is likely easiest from a parsing perspective, as it does not require using look-ahead, but it is perhaps not too onerous to only accept it for `fn`s (and all their various qualifiers), `const`s, `static`s, and `type`s.
r? @petrochenkovFile tree
77 files changed
+1314
-714
lines changed- src
- librustc_ast_lowering
- librustc_ast_passes
- librustc_ast_pretty
- librustc_builtin_macros
- deriving/generic
- librustc_expand
- librustc_interface
- librustc_lint
- librustc_parse/parser
- librustc_resolve
- librustc_save_analysis
- libsyntax
- test/ui
- did_you_mean
- extern
- issues
- macros
- parser
- macro
- mismatched-braces
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
77 files changed
+1314
-714
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
| 272 | + | |
| 273 | + | |
281 | 274 | | |
282 | 275 | | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
| 276 | + | |
| 277 | + | |
292 | 278 | | |
293 | 279 | | |
294 | 280 | | |
| |||
457 | 443 | | |
458 | 444 | | |
459 | 445 | | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
460 | 461 | | |
461 | 462 | | |
462 | 463 | | |
| |||
678 | 679 | | |
679 | 680 | | |
680 | 681 | | |
681 | | - | |
| 682 | + | |
682 | 683 | | |
683 | 684 | | |
684 | 685 | | |
685 | | - | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
686 | 692 | | |
687 | 693 | | |
688 | 694 | | |
| |||
759 | 765 | | |
760 | 766 | | |
761 | 767 | | |
762 | | - | |
763 | | - | |
| 768 | + | |
| 769 | + | |
764 | 770 | | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
| 771 | + | |
| 772 | + | |
772 | 773 | | |
773 | | - | |
| 774 | + | |
774 | 775 | | |
775 | 776 | | |
776 | | - | |
| 777 | + | |
777 | 778 | | |
778 | 779 | | |
779 | | - | |
| 780 | + | |
780 | 781 | | |
781 | 782 | | |
782 | | - | |
| 783 | + | |
783 | 784 | | |
784 | 785 | | |
785 | | - | |
| 786 | + | |
786 | 787 | | |
787 | | - | |
| 788 | + | |
788 | 789 | | |
789 | 790 | | |
790 | 791 | | |
| |||
806 | 807 | | |
807 | 808 | | |
808 | 809 | | |
809 | | - | |
810 | | - | |
811 | | - | |
812 | | - | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
813 | 817 | | |
814 | 818 | | |
815 | 819 | | |
| |||
832 | 836 | | |
833 | 837 | | |
834 | 838 | | |
835 | | - | |
836 | | - | |
| 839 | + | |
837 | 840 | | |
838 | 841 | | |
839 | | - | |
| 842 | + | |
840 | 843 | | |
841 | 844 | | |
842 | 845 | | |
843 | | - | |
| 846 | + | |
844 | 847 | | |
845 | 848 | | |
846 | 849 | | |
847 | 850 | | |
848 | 851 | | |
849 | 852 | | |
850 | | - | |
| 853 | + | |
851 | 854 | | |
852 | 855 | | |
853 | 856 | | |
| |||
856 | 859 | | |
857 | 860 | | |
858 | 861 | | |
859 | | - | |
860 | | - | |
| 862 | + | |
| 863 | + | |
861 | 864 | | |
862 | 865 | | |
863 | 866 | | |
| |||
901 | 904 | | |
902 | 905 | | |
903 | 906 | | |
904 | | - | |
905 | | - | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
906 | 910 | | |
907 | 911 | | |
908 | 912 | | |
909 | 913 | | |
910 | 914 | | |
911 | | - | |
| 915 | + | |
912 | 916 | | |
913 | 917 | | |
914 | 918 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
490 | 490 | | |
491 | 491 | | |
492 | 492 | | |
493 | | - | |
| 493 | + | |
494 | 494 | | |
495 | 495 | | |
496 | 496 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
| |||
423 | 426 | | |
424 | 427 | | |
425 | 428 | | |
426 | | - | |
| 429 | + | |
427 | 430 | | |
428 | 431 | | |
429 | 432 | | |
430 | 433 | | |
431 | 434 | | |
432 | 435 | | |
433 | | - | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
434 | 485 | | |
435 | 486 | | |
436 | 487 | | |
| |||
458 | 509 | | |
459 | 510 | | |
460 | 511 | | |
461 | | - | |
| 512 | + | |
462 | 513 | | |
463 | 514 | | |
464 | 515 | | |
| |||
531 | 582 | | |
532 | 583 | | |
533 | 584 | | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
534 | 595 | | |
535 | 596 | | |
536 | 597 | | |
| |||
900 | 961 | | |
901 | 962 | | |
902 | 963 | | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
903 | 972 | | |
904 | 973 | | |
905 | 974 | | |
| |||
912 | 981 | | |
913 | 982 | | |
914 | 983 | | |
915 | | - | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
916 | 993 | | |
917 | 994 | | |
918 | 995 | | |
| |||
1154 | 1231 | | |
1155 | 1232 | | |
1156 | 1233 | | |
1157 | | - | |
| 1234 | + | |
1158 | 1235 | | |
1159 | 1236 | | |
1160 | | - | |
| 1237 | + | |
1161 | 1238 | | |
1162 | | - | |
| 1239 | + | |
1163 | 1240 | | |
1164 | 1241 | | |
1165 | 1242 | | |
1166 | 1243 | | |
1167 | 1244 | | |
1168 | 1245 | | |
1169 | 1246 | | |
1170 | | - | |
| 1247 | + | |
1171 | 1248 | | |
1172 | 1249 | | |
1173 | 1250 | | |
1174 | 1251 | | |
1175 | 1252 | | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
1176 | 1257 | | |
1177 | 1258 | | |
1178 | 1259 | | |
| |||
0 commit comments