Commit e842dea
committed
Auto merge of #52618 - alexcrichton:capture-more, r=petrochenkov
rustc: Implement tokenization of nested items
Ever plagued by #43081 the compiler can return surprising spans in situations
related to procedural macros. This is exhibited by #47983 where whenever a
procedural macro is invoked in a nested item context it would fail to have
correct span information.
While #43230 provided a "hack" to cache the token stream used for each item in
the compiler it's not a full-blown solution. This commit continues to extend
this "hack" a bit more to work for nested items.
Previously in the parser the `parse_item` method would collect the tokens for an
item into a cache on the item itself. It turned out, however, that nested items
were parsed through the `parse_item_` method, so they didn't receive similar
treatment. To remedy this situation the hook for collecting tokens was moved
into `parse_item_` instead of `parse_item`.
Afterwards the token collection scheme was updated to support nested collection
of tokens. This is implemented by tracking `TokenStream` tokens instead of
`TokenTree` to allow for collecting items into streams at intermediate layers
and having them interleaved in the upper layers.
All in all, this...
Closes #47983File tree
5 files changed
+156
-43
lines changed- src
- libsyntax
- parse
- test/ui-fulldeps/proc-macro
- auxiliary
5 files changed
+156
-43
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | | - | |
292 | | - | |
| 291 | + | |
| 292 | + | |
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
| |||
326 | 326 | | |
327 | 327 | | |
328 | 328 | | |
329 | | - | |
330 | | - | |
| 329 | + | |
| 330 | + | |
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
| |||
6723 | 6723 | | |
6724 | 6724 | | |
6725 | 6725 | | |
| 6726 | + | |
| 6727 | + | |
| 6728 | + | |
| 6729 | + | |
| 6730 | + | |
| 6731 | + | |
| 6732 | + | |
| 6733 | + | |
| 6734 | + | |
| 6735 | + | |
| 6736 | + | |
| 6737 | + | |
| 6738 | + | |
| 6739 | + | |
| 6740 | + | |
| 6741 | + | |
| 6742 | + | |
| 6743 | + | |
| 6744 | + | |
| 6745 | + | |
| 6746 | + | |
| 6747 | + | |
| 6748 | + | |
| 6749 | + | |
| 6750 | + | |
| 6751 | + | |
| 6752 | + | |
| 6753 | + | |
| 6754 | + | |
| 6755 | + | |
| 6756 | + | |
| 6757 | + | |
| 6758 | + | |
| 6759 | + | |
6726 | 6760 | | |
6727 | 6761 | | |
6728 | 6762 | | |
6729 | | - | |
6730 | | - | |
| 6763 | + | |
| 6764 | + | |
| 6765 | + | |
| 6766 | + | |
| 6767 | + | |
| 6768 | + | |
6731 | 6769 | | |
6732 | 6770 | | |
6733 | 6771 | | |
| |||
7260 | 7298 | | |
7261 | 7299 | | |
7262 | 7300 | | |
7263 | | - | |
7264 | | - | |
7265 | | - | |
| 7301 | + | |
| 7302 | + | |
| 7303 | + | |
7266 | 7304 | | |
7267 | | - | |
7268 | | - | |
| 7305 | + | |
| 7306 | + | |
| 7307 | + | |
| 7308 | + | |
| 7309 | + | |
7269 | 7310 | | |
7270 | 7311 | | |
7271 | 7312 | | |
| |||
7274 | 7315 | | |
7275 | 7316 | | |
7276 | 7317 | | |
7277 | | - | |
| 7318 | + | |
| 7319 | + | |
| 7320 | + | |
7278 | 7321 | | |
7279 | 7322 | | |
7280 | 7323 | | |
7281 | 7324 | | |
7282 | 7325 | | |
7283 | 7326 | | |
7284 | 7327 | | |
7285 | | - | |
7286 | | - | |
| 7328 | + | |
| 7329 | + | |
7287 | 7330 | | |
7288 | | - | |
| 7331 | + | |
| 7332 | + | |
| 7333 | + | |
| 7334 | + | |
| 7335 | + | |
| 7336 | + | |
| 7337 | + | |
| 7338 | + | |
| 7339 | + | |
| 7340 | + | |
| 7341 | + | |
| 7342 | + | |
| 7343 | + | |
| 7344 | + | |
| 7345 | + | |
| 7346 | + | |
| 7347 | + | |
7289 | 7348 | | |
7290 | 7349 | | |
7291 | | - | |
| 7350 | + | |
7292 | 7351 | | |
7293 | 7352 | | |
7294 | 7353 | | |
7295 | 7354 | | |
7296 | | - | |
7297 | | - | |
7298 | | - | |
7299 | | - | |
7300 | | - | |
7301 | | - | |
7302 | | - | |
7303 | | - | |
7304 | | - | |
7305 | | - | |
7306 | | - | |
7307 | | - | |
7308 | | - | |
7309 | | - | |
7310 | | - | |
7311 | | - | |
7312 | | - | |
7313 | | - | |
7314 | | - | |
7315 | | - | |
7316 | | - | |
7317 | | - | |
7318 | | - | |
7319 | | - | |
7320 | | - | |
7321 | | - | |
7322 | | - | |
| 7355 | + | |
7323 | 7356 | | |
7324 | 7357 | | |
7325 | 7358 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
| 343 | + | |
343 | 344 | | |
344 | 345 | | |
345 | 346 | | |
| |||
Lines changed: 22 additions & 0 deletions
| 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 | + | |
| 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 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 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 | + | |
0 commit comments