rust/src/libsyntax/parse
bors 9622f9dc47 Auto merge of #56647 - petrochenkov:dcrate2, r=alexcrichton
Rework treatment of `$crate` in procedural macros

Important clarification: `$crate` below means "processed `$crate`" or "output `$crate`". In the input of a decl macro `$crate` is just two separate tokens, but in the *output of a decl macro* `$crate` is a single keyword identifier (https://github.com/rust-lang/rust/issues/55640#issuecomment-435692791).

First of all, this PR removes the `eliminate_crate_var` hack.
`$crate::foo` is no longer replaced with `::foo` or `::crate_name::foo` in the input of derive proc macros, it's passed to the macro instead with its precise span and hygiene data, and can be treated as any other path segment keyword (like `crate` or `self`) after that. (Note: `eliminate_crate_var` was never used for non-derive proc macros.)

This creates an annoying problem - derive macros still may stringify their input before processing and expect `$crate` survive that stringification and refer to the same crate (the Rust 1.15-1.29 way of doing things).
Moreover, the input of proc macro attributes and derives (but not fn-like proc macros) also effectively survives stringification before being passed to the macro (also for legacy implementation reasons).

So we kind of resurrect the `eliminate_crate_var` hack in reduced form, but apply it only to AST pretty-printing.
If an AST fragment is pretty-printed, the resulting *text* will have `$crate` replaced with `crate` or `::crate_name`. This should be enough to keep all the legacy cases working.

Closes https://github.com/rust-lang/rust/issues/55640
Closes https://github.com/rust-lang/rust/issues/56622
r? @ghost
2018-12-20 12:42:54 +00:00
..
lexer Rollup merge of #56910 - estebank:unclosed-eof, r=oli-obk 2018-12-19 11:47:14 +01:00
attr.rs Rename TokenStream::concat and remove TokenStream::concat_rc_vec. 2018-12-12 20:36:00 +11:00
classify.rs Rename Catch variants to TryBlock 2018-08-19 16:30:53 -07:00
mod.rs Tweak query code for performance 2018-12-17 08:53:01 +01:00
parser.rs Rollup merge of #56820 - ljedrz:format_tweaks, r=alexcrichton 2018-12-19 11:47:09 +01:00
token.rs Do not interpret mismatches from pretty-printed $crate as token stream invalidation 2018-12-19 23:17:54 +03:00