Skip to content

Commit 6a0962f

Browse files
committed
add idents to the symbol gallery when converting to internal
1 parent dd916c7 commit 6a0962f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

compiler/rustc_expand/src/proc_macro_server.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,12 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec<TokenTree<TokenStre
236236
}
237237
}
238238

239-
impl ToInternal<TokenStream> for TokenTree<TokenStream, Span, Symbol> {
239+
impl ToInternal<TokenStream> for (TokenTree<TokenStream, Span, Symbol>, &mut Rustc<'_, '_>) {
240240
fn to_internal(self) -> TokenStream {
241241
use rustc_ast::token::*;
242242

243-
let (ch, joint, span) = match self {
243+
let (tree, rustc) = self;
244+
let (ch, joint, span) = match tree {
244245
TokenTree::Punct(Punct { ch, joint, span }) => (ch, joint, span),
245246
TokenTree::Group(Group { delimiter, stream, span: DelimSpan { open, close, .. } }) => {
246247
return tokenstream::TokenTree::Delimited(
@@ -251,6 +252,7 @@ impl ToInternal<TokenStream> for TokenTree<TokenStream, Span, Symbol> {
251252
.into();
252253
}
253254
TokenTree::Ident(self::Ident { sym, is_raw, span }) => {
255+
rustc.sess().symbol_gallery.insert(sym, span);
254256
return tokenstream::TokenTree::token(Ident(sym, is_raw), span).into();
255257
}
256258
TokenTree::Literal(self::Literal {
@@ -540,7 +542,7 @@ impl server::TokenStream for Rustc<'_, '_> {
540542
&mut self,
541543
tree: TokenTree<Self::TokenStream, Self::Span, Self::Symbol>,
542544
) -> Self::TokenStream {
543-
tree.to_internal()
545+
(tree, self).to_internal()
544546
}
545547
fn concat_trees(
546548
&mut self,
@@ -552,7 +554,7 @@ impl server::TokenStream for Rustc<'_, '_> {
552554
builder.push(base);
553555
}
554556
for tree in trees {
555-
builder.push(tree.to_internal());
557+
builder.push((tree, &mut *self).to_internal());
556558
}
557559
builder.build()
558560
}

0 commit comments

Comments
 (0)