mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-02 18:27:37 +00:00

Fix `proc_macro::Ident`'s handling of `$crate` This PR is addresses a few minor bugs, all relating to `proc_macro::Ident`'s support for `$crate`. `Ident` currently supports `$crate` (as can be seen in the `mixed-site-span` test), but: * `proc_macro::Symbol::can_be_raw` is out of sync with `rustc_span::Symbol::can_be_raw` * former doesn't cover `$crate` while the latter does cover `kw::DollarCrate` * `Ident::new` rejects `$crate` * This conflicts with the [reference definition](https://doc.rust-lang.org/nightly/reference/macros-by-example.html#r-macro.decl.meta.specifier) of `ident` which includes `$crate`. * This also conflicts with the documentation on [`Display for Ident`](https://doc.rust-lang.org/proc_macro/struct.Ident.html#impl-Display-for-Ident) which says the output "should be losslessly convertible back into the same identifier". This PR fixes the above issues and extends the `mixed-site-span` test to exercise these fixed code paths, as well as validating the different possible spans resolve `$crate` as expected (for both the new and old `$crate` construction code paths).