Commit 30a4e9e
committed
Fix the
This commit is a stab at getting the `proc_macro2` crate to function outside the
context of the compiler, **even when the `nightly` feature is enabled**.
Previously when the `nightly` feature was enabled then `proc_macro2` would panic
at runtime because `proc_macro` itself would panic at runtime due to the lack of
the compiler being initialized.
In this commit the `unstable` module in `proc_macro2` no longer unconditionally
uses the `proc_macro` upstream crate but is rather an `enum` over the upstream
crate and the `stable` module. At runtime the appropriate implementation is
dynamically selected depending on which works.
This brings up some uncomfortable issues such as what happens when you try to
psas a "stable span" to a "nightly `Literal`", but I think we can paper over
these issues in time by further canonicalizing everything to nightly/stable if
it comes up.
One caveat this brings up is that `Span::unstable` unconditionally panics when
outside the compiler, but I think that's expected regardless.nightly feature outside of rustc1 parent 6b46deb commit 30a4e9e
5 files changed
+378
-115
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
| 14 | + | |
| 15 | + | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
52 | | - | |
53 | 51 | | |
54 | 52 | | |
55 | 53 | | |
| |||
59 | 57 | | |
60 | 58 | | |
61 | 59 | | |
62 | | - | |
63 | 60 | | |
| 61 | + | |
64 | 62 | | |
65 | | - | |
66 | 63 | | |
67 | | - | |
| 64 | + | |
68 | 65 | | |
69 | 66 | | |
70 | 67 | | |
| |||
88 | 85 | | |
89 | 86 | | |
90 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
91 | 95 | | |
92 | 96 | | |
93 | 97 | | |
| |||
201 | 205 | | |
202 | 206 | | |
203 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
204 | 215 | | |
205 | 216 | | |
206 | 217 | | |
| |||
525 | 536 | | |
526 | 537 | | |
527 | 538 | | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
528 | 546 | | |
529 | 547 | | |
530 | 548 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
171 | 170 | | |
172 | 171 | | |
173 | 172 | | |
174 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
175 | 177 | | |
176 | 178 | | |
177 | 179 | | |
178 | 180 | | |
179 | 181 | | |
180 | 182 | | |
181 | | - | |
182 | 183 | | |
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
186 | 187 | | |
187 | | - | |
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
201 | 200 | | |
202 | 201 | | |
203 | 202 | | |
204 | 203 | | |
205 | 204 | | |
206 | 205 | | |
207 | | - | |
208 | 206 | | |
209 | 207 | | |
210 | 208 | | |
| |||
214 | 212 | | |
215 | 213 | | |
216 | 214 | | |
217 | | - | |
218 | 215 | | |
219 | 216 | | |
220 | 217 | | |
| |||
660 | 657 | | |
661 | 658 | | |
662 | 659 | | |
663 | | - | |
| 660 | + | |
664 | 661 | | |
665 | 662 | | |
666 | 663 | | |
| |||
680 | 677 | | |
681 | 678 | | |
682 | 679 | | |
683 | | - | |
| 680 | + | |
684 | 681 | | |
685 | 682 | | |
686 | 683 | | |
| |||
689 | 686 | | |
690 | 687 | | |
691 | 688 | | |
692 | | - | |
| 689 | + | |
693 | 690 | | |
694 | 691 | | |
695 | 692 | | |
| |||
701 | 698 | | |
702 | 699 | | |
703 | 700 | | |
704 | | - | |
| 701 | + | |
705 | 702 | | |
706 | 703 | | |
707 | 704 | | |
| |||
714 | 711 | | |
715 | 712 | | |
716 | 713 | | |
717 | | - | |
| 714 | + | |
718 | 715 | | |
719 | 716 | | |
720 | 717 | | |
| |||
726 | 723 | | |
727 | 724 | | |
728 | 725 | | |
729 | | - | |
| 726 | + | |
730 | 727 | | |
731 | 728 | | |
732 | 729 | | |
733 | 730 | | |
734 | 731 | | |
735 | | - | |
| 732 | + | |
736 | 733 | | |
737 | 734 | | |
738 | 735 | | |
739 | 736 | | |
740 | 737 | | |
741 | | - | |
| 738 | + | |
742 | 739 | | |
743 | 740 | | |
744 | 741 | | |
| |||
792 | 789 | | |
793 | 790 | | |
794 | 791 | | |
795 | | - | |
| 792 | + | |
796 | 793 | | |
797 | 794 | | |
798 | 795 | | |
| |||
802 | 799 | | |
803 | 800 | | |
804 | 801 | | |
805 | | - | |
| 802 | + | |
806 | 803 | | |
807 | 804 | | |
808 | 805 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
0 commit comments