mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
2b2462e8b0
Currently, the rustc_macros::symbols macro generates two `macro_rules!` macros as its output. These two macros are used in rustc_span/src/symbol.rs. This means that each Symbol that we define is represented in the AST of rustc_symbols twice: once in the definition of the `define_symbols!` macro (similarly for the `keywords! macro), and once in the rustc_span::symbols definition. That would be OK if there were only a handful of symbols, but currently we define over 1100 symbols. The definition of the `define_symbols!` macro contains the expanded definition of each symbol, so that's a lot of AST storage wasted on a macro that is used exactly once. This commit removes the `define_symbols` macro, and simply allows the proc macro to directly generate the `rustc_symbols::symbol::sym` module. The benefit is mainly in reducing memory wasted during compilation of rustc itself. It should also reduce memory used by Rust Analyzer. This commit also reduces the size of the AST for symbol definitions, by moving two `#[allow(...)]` attributes from the symbol constants to the `sym` module. This eliminates 2200+ attribute nodes. This commit also eliminates the need for the `digits_array` constant. There's no need to store an array of Symbol values for digits. We can simply define a constant of the base value, and add to that base value. |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |