mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 13:48:50 +00:00
fix: Fix TokenStream::to_string implementation dropping quotation marks
This commit is contained in:
parent
d6666b16c4
commit
abed6e24a8
2 changed files with 8 additions and 3 deletions
|
@ -507,12 +507,17 @@ mod tests {
|
||||||
close: span,
|
close: span,
|
||||||
kind: tt::DelimiterKind::Brace,
|
kind: tt::DelimiterKind::Brace,
|
||||||
},
|
},
|
||||||
token_trees: Box::new([]),
|
token_trees: Box::new([tt::TokenTree::Leaf(tt::Leaf::Literal(tt::Literal {
|
||||||
|
kind: tt::LitKind::Str,
|
||||||
|
symbol: Symbol::intern("string"),
|
||||||
|
suffix: None,
|
||||||
|
span,
|
||||||
|
}))]),
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
assert_eq!(s.to_string(), "struct T {}");
|
assert_eq!(s.to_string(), "struct T {\"string\"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -603,7 +603,7 @@ pub fn pretty<S>(tkns: &[TokenTree<S>]) -> String {
|
||||||
TokenTree::Leaf(Leaf::Ident(ident)) => {
|
TokenTree::Leaf(Leaf::Ident(ident)) => {
|
||||||
format!("{}{}", ident.is_raw.as_str(), ident.sym)
|
format!("{}{}", ident.is_raw.as_str(), ident.sym)
|
||||||
}
|
}
|
||||||
TokenTree::Leaf(Leaf::Literal(literal)) => literal.symbol.as_str().to_owned(),
|
TokenTree::Leaf(Leaf::Literal(literal)) => format!("{literal}"),
|
||||||
TokenTree::Leaf(Leaf::Punct(punct)) => format!("{}", punct.char),
|
TokenTree::Leaf(Leaf::Punct(punct)) => format!("{}", punct.char),
|
||||||
TokenTree::Subtree(subtree) => {
|
TokenTree::Subtree(subtree) => {
|
||||||
let content = pretty(&subtree.token_trees);
|
let content = pretty(&subtree.token_trees);
|
||||||
|
|
Loading…
Reference in a new issue