diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2025-04-21 12:34:59 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-21 12:34:59 +0000 |
| commit | b6eb883b1f897fc7e52fde3d87efb2fff47022f2 (patch) | |
| tree | 0d2080fbc3fc40a4b149911ec427b2a6aa800cff /src/tools/rust-analyzer/crates/intern | |
| parent | d7ddec67f2dd861118268df227ea91eea4f1bdb8 (diff) | |
| parent | 3b2bb61dc877d0f134b3e92868695b02a36df703 (diff) | |
| download | rust-b6eb883b1f897fc7e52fde3d87efb2fff47022f2.tar.gz rust-b6eb883b1f897fc7e52fde3d87efb2fff47022f2.zip | |
Merge pull request #19644 from ChayimFriedman2/const-syms
internal: Make predefined symbols `const` instead of `static`
Diffstat (limited to 'src/tools/rust-analyzer/crates/intern')
| -rw-r--r-- | src/tools/rust-analyzer/crates/intern/src/symbol/symbols.rs | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/src/tools/rust-analyzer/crates/intern/src/symbol/symbols.rs b/src/tools/rust-analyzer/crates/intern/src/symbol/symbols.rs index 49c1c955b2d..3effc668abb 100644 --- a/src/tools/rust-analyzer/crates/intern/src/symbol/symbols.rs +++ b/src/tools/rust-analyzer/crates/intern/src/symbol/symbols.rs @@ -13,35 +13,18 @@ use crate::{ macro_rules! define_symbols { (@WITH_NAME: $($alias:ident = $value:literal,)* @PLAIN: $($name:ident,)*) => { - // We define symbols as both `const`s and `static`s because some const code requires const symbols, - // but code from before the transition relies on the lifetime of the predefined symbols and making them - // `const`s make it error (because now they're temporaries). In the future we probably should only - // use consts. - - /// Predefined symbols as `const`s (instead of the default `static`s). - pub mod consts { - use super::{Symbol, TaggedArcPtr}; - - // The strings should be in `static`s so that symbol equality holds. - $( - pub const $name: Symbol = { - static SYMBOL_STR: &str = stringify!($name); - Symbol { repr: TaggedArcPtr::non_arc(&SYMBOL_STR) } - }; - )* - $( - pub const $alias: Symbol = { - static SYMBOL_STR: &str = $value; - Symbol { repr: TaggedArcPtr::non_arc(&SYMBOL_STR) } - }; - )* - } - + // The strings should be in `static`s so that symbol equality holds. $( - pub static $name: Symbol = consts::$name; + pub const $name: Symbol = { + static SYMBOL_STR: &str = stringify!($name); + Symbol { repr: TaggedArcPtr::non_arc(&SYMBOL_STR) } + }; )* $( - pub static $alias: Symbol = consts::$alias; + pub const $alias: Symbol = { + static SYMBOL_STR: &str = $value; + Symbol { repr: TaggedArcPtr::non_arc(&SYMBOL_STR) } + }; )* |
