Merge pull request #19822 from Veykril/push-mzzluystvwls
Some checks are pending
metrics / build_metrics (push) Waiting to run
metrics / other_metrics (diesel-1.4.8) (push) Blocked by required conditions
metrics / other_metrics (hyper-0.14.18) (push) Blocked by required conditions
metrics / other_metrics (ripgrep-13.0.0) (push) Blocked by required conditions
metrics / other_metrics (self) (push) Blocked by required conditions
metrics / other_metrics (webrender-2022) (push) Blocked by required conditions
metrics / generate_final_metrics (push) Blocked by required conditions
rustdoc / rustdoc (push) Waiting to run

minor: Remote dangling file
This commit is contained in:
Lukas Wirth 2025-05-19 11:20:03 +00:00 committed by GitHub
commit 59ef84506d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 1 additions and 49 deletions

View file

@ -16,9 +16,8 @@ mod token_stream;
pub use token_stream::TokenStream;
pub mod rust_analyzer_span;
// mod symbol;
pub mod token_id;
// pub use symbol::*;
use tt::Spacing;
#[derive(Clone)]

View file

@ -1,47 +0,0 @@
//! Symbol interner for proc-macro-srv
use std::{cell::RefCell, collections::HashMap, thread::LocalKey};
thread_local! {
pub(crate) static SYMBOL_INTERNER: RefCell<SymbolInterner> = Default::default();
}
// ID for an interned symbol.
#[derive(Hash, Eq, PartialEq, Copy, Clone)]
pub struct Symbol(u32);
pub(crate) type SymbolInternerRef = &'static LocalKey<RefCell<SymbolInterner>>;
impl Symbol {
pub(super) fn intern(interner: SymbolInternerRef, data: &str) -> Symbol {
interner.with(|i| i.borrow_mut().intern(data))
}
pub(super) fn text(&self, interner: SymbolInternerRef) -> SmolStr {
interner.with(|i| i.borrow().get(self).clone())
}
}
#[derive(Default)]
pub(crate) struct SymbolInterner {
idents: HashMap<SmolStr, u32>,
ident_data: Vec<SmolStr>,
}
impl SymbolInterner {
fn intern(&mut self, data: &str) -> Symbol {
if let Some(index) = self.idents.get(data) {
return Symbol(*index);
}
let index = self.idents.len() as u32;
let data = SmolStr::from(data);
self.ident_data.push(data.clone());
self.idents.insert(data, index);
Symbol(index)
}
fn get(&self, sym: &Symbol) -> &SmolStr {
&self.ident_data[sym.0 as usize]
}
}