diff options
| author | bors <bors@rust-lang.org> | 2021-04-11 07:36:33 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-04-11 07:36:33 +0000 |
| commit | ba6275b6a9fc05fd5d93220e9a67fe64d663cb62 (patch) | |
| tree | 2c6fa2b3968f6fccbf8e44a70a873edeb4124946 /library/std/src/sys/hermit/stack_overflow.rs | |
| parent | 28b948fc5c0163b76c69d792b91a0e83850e7e54 (diff) | |
| parent | a93c4f05de5c5cdd8158e23de7c3cf86a548447f (diff) | |
| download | rust-ba6275b6a9fc05fd5d93220e9a67fe64d663cb62.tar.gz rust-ba6275b6a9fc05fd5d93220e9a67fe64d663cb62.zip | |
Auto merge of #82608 - Aaron1011:feature/final-preexp-tts, r=petrochenkov
Implement token-based handling of attributes during expansion This PR modifies the macro expansion infrastructure to handle attributes in a fully token-based manner. As a result: * Derives macros no longer lose spans when their input is modified by eager cfg-expansion. This is accomplished by performing eager cfg-expansion on the token stream that we pass to the derive proc-macro * Inner attributes now preserve spans in all cases, including when we have multiple inner attributes in a row. This is accomplished through the following changes: * New structs `AttrAnnotatedTokenStream` and `AttrAnnotatedTokenTree` are introduced. These are very similar to a normal `TokenTree`, but they also track the position of attributes and attribute targets within the stream. They are built when we collect tokens during parsing. An `AttrAnnotatedTokenStream` is converted to a regular `TokenStream` when we invoke a macro. * Token capturing and `LazyTokenStream` are modified to work with `AttrAnnotatedTokenStream`. A new `ReplaceRange` type is introduced, which is created during the parsing of a nested AST node to make the 'outer' AST node aware of the attributes and attribute target stored deeper in the token stream. * When we need to perform eager cfg-expansion (either due to `#[derive]` or `#[cfg_eval]`), we tokenize and reparse our target, capturing additional information about the locations of `#[cfg]` and `#[cfg_attr]` attributes at any depth within the target. This is a performance optimization, allowing us to perform less work in the typical case where captured tokens never have eager cfg-expansion run.
Diffstat (limited to 'library/std/src/sys/hermit/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions
