Skip to content

Commit 03d6745

Browse files
committed
fix: Fix TokenStream::to_string implementation dropping quotation marks
1 parent 14ec120 commit 03d6745

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -507,12 +507,17 @@ mod tests {
507507
close: span,
508508
kind: tt::DelimiterKind::Brace,
509509
},
510-
token_trees: Box::new([]),
510+
token_trees: Box::new([tt::TokenTree::Leaf(tt::Leaf::Literal(tt::Literal {
511+
kind: tt::LitKind::Str,
512+
symbol: Symbol::intern("string"),
513+
suffix: None,
514+
span,
515+
}))]),
511516
}),
512517
],
513518
};
514519

515-
assert_eq!(s.to_string(), "struct T {}");
520+
assert_eq!(s.to_string(), "struct T {\"string\"}");
516521
}
517522

518523
#[test]

src/tools/rust-analyzer/crates/tt/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ pub fn pretty<S>(tkns: &[TokenTree<S>]) -> String {
603603
TokenTree::Leaf(Leaf::Ident(ident)) => {
604604
format!("{}{}", ident.is_raw.as_str(), ident.sym)
605605
}
606-
TokenTree::Leaf(Leaf::Literal(literal)) => literal.symbol.as_str().to_owned(),
606+
TokenTree::Leaf(Leaf::Literal(literal)) => format!("{literal}"),
607607
TokenTree::Leaf(Leaf::Punct(punct)) => format!("{}", punct.char),
608608
TokenTree::Subtree(subtree) => {
609609
let content = pretty(&subtree.token_trees);

0 commit comments

Comments
 (0)