]> git.lizzy.rs Git - rust.git/commit
proc_macro: stop using a remote object handle for Ident
authorNika Layzell <nika@thelayzells.com>
Fri, 1 Jul 2022 01:05:46 +0000 (21:05 -0400)
committerNika Layzell <nika@thelayzells.com>
Mon, 18 Jul 2022 16:59:14 +0000 (12:59 -0400)
commit491fccfbe3561b0674a7dd13ac9f00820662aa59
tree004f1977288b1841cbd150e4e9e376d0350da11a
parente0dce6ec8df23adbe7c45c07ed080caf3d81a14b
proc_macro: stop using a remote object handle for Ident

Doing this for all unicode identifiers would require a dependency on
`unicode-normalization` and `rustc_lexer`, which is currently not
possible for `proc_macro` due to it being built concurrently with `std`
and `core`. Instead, ASCII identifiers are validated locally, and an RPC
message is used to validate unicode identifiers when needed.

String values are interned on the both the server and client when
deserializing, to avoid unnecessary copies and keep Ident cheap to copy and
move. This appears to be important for performance.

The client-side interner is based roughly on the one from rustc_span, and uses
an arena inspired by rustc_arena.

RPC messages passing symbols always include the full value. This could
potentially be optimized in the future if it is revealed to be a
performance bottleneck.

Despite now having a relevant implementaion of Display for Ident, ToString is
still specialized, as it is a hot-path for this object.

The symbol infrastructure will also be used for literals in the next
part.
compiler/rustc_expand/src/proc_macro_server.rs
library/proc_macro/src/bridge/arena.rs [new file with mode: 0644]
library/proc_macro/src/bridge/client.rs
library/proc_macro/src/bridge/mod.rs
library/proc_macro/src/bridge/server.rs
library/proc_macro/src/bridge/symbol.rs [new file with mode: 0644]
library/proc_macro/src/lib.rs
src/test/ui/proc-macro/invalid-punct-ident-2.rs
src/test/ui/proc-macro/invalid-punct-ident-2.stderr
src/test/ui/proc-macro/invalid-punct-ident-3.rs
src/test/ui/proc-macro/invalid-punct-ident-3.stderr