mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Move TokenStream::to_string helpers inside the method
This commit is contained in:
parent
93c9b34635
commit
aea9749390
@ -199,14 +199,16 @@ pub mod token_stream {
|
|||||||
|
|
||||||
impl ToString for TokenStream {
|
impl ToString for TokenStream {
|
||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
tokentrees_to_text(&self.token_trees[..])
|
return tokentrees_to_text(&self.token_trees[..]);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn tokentrees_to_text(tkns: &[tt::TokenTree]) -> String {
|
fn tokentrees_to_text(tkns: &[tt::TokenTree]) -> String {
|
||||||
tkns.iter()
|
tkns.iter()
|
||||||
.fold((String::new(), true), |(last, last_to_joint), tkn| {
|
.fold((String::new(), true), |(last, last_to_joint), tkn| {
|
||||||
let s = [last, tokentree_to_text(tkn)].join(if last_to_joint { "" } else { " " });
|
let s = [last, tokentree_to_text(tkn)].join(if last_to_joint {
|
||||||
|
""
|
||||||
|
} else {
|
||||||
|
" "
|
||||||
|
});
|
||||||
let mut is_joint = false;
|
let mut is_joint = false;
|
||||||
if let tt::TokenTree::Leaf(tt::Leaf::Punct(punct)) = tkn {
|
if let tt::TokenTree::Leaf(tt::Leaf::Punct(punct)) = tkn {
|
||||||
if punct.spacing == tt::Spacing::Joint {
|
if punct.spacing == tt::Spacing::Joint {
|
||||||
@ -235,6 +237,8 @@ pub mod token_stream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn subtree_replace_token_ids_with_unspecified(subtree: tt::Subtree) -> tt::Subtree {
|
fn subtree_replace_token_ids_with_unspecified(subtree: tt::Subtree) -> tt::Subtree {
|
||||||
tt::Subtree {
|
tt::Subtree {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user