aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-12-13 14:02:26 +0000
committerGitHub <[email protected]>2019-12-13 14:02:26 +0000
commitebc95af2b5b91239fc1d8a5fc8344ded6f6ef3e4 (patch)
treefe84a7b9a434cb268faea247d9d6dbffed894696 /crates/ra_hir_expand
parent16cf6bcf4b614a7a1a3a3f3659f7bb3df7cff086 (diff)
parent98f98cbb5404385703a404547aa2477d4a2fd1cb (diff)
Merge #2551
2551: Refactor tt::Subtree delimiter r=matklad a=edwin0cheng Refactor to : ``` #[derive(Debug, Clone, PartialEq, Eq, Hash, Default)] pub struct Subtree { pub delimiter: Option<Delimiter>, pub token_trees: Vec<TokenTree>, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum Delimiter { Parenthesis, Brace, Bracket, } ``` Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir_expand')
-rw-r--r--crates/ra_hir_expand/src/quote.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/ra_hir_expand/src/quote.rs b/crates/ra_hir_expand/src/quote.rs
index 4f698ff13..aa8a5f23f 100644
--- a/crates/ra_hir_expand/src/quote.rs
+++ b/crates/ra_hir_expand/src/quote.rs
@@ -16,7 +16,7 @@ macro_rules! __quote {
16 { 16 {
17 let children = $crate::__quote!($($tt)*); 17 let children = $crate::__quote!($($tt)*);
18 let subtree = tt::Subtree { 18 let subtree = tt::Subtree {
19 delimiter: tt::Delimiter::$delim, 19 delimiter: Some(tt::Delimiter::$delim),
20 token_trees: $crate::quote::IntoTt::to_tokens(children), 20 token_trees: $crate::quote::IntoTt::to_tokens(children),
21 }; 21 };
22 subtree 22 subtree
@@ -124,7 +124,7 @@ pub(crate) trait IntoTt {
124 124
125impl IntoTt for Vec<tt::TokenTree> { 125impl IntoTt for Vec<tt::TokenTree> {
126 fn to_subtree(self) -> tt::Subtree { 126 fn to_subtree(self) -> tt::Subtree {
127 tt::Subtree { delimiter: tt::Delimiter::None, token_trees: self } 127 tt::Subtree { delimiter: None, token_trees: self }
128 } 128 }
129 129
130 fn to_tokens(self) -> Vec<tt::TokenTree> { 130 fn to_tokens(self) -> Vec<tt::TokenTree> {
@@ -254,7 +254,8 @@ mod tests {
254 let fields = 254 let fields =
255 fields.iter().map(|it| quote!(#it: self.#it.clone(), ).token_trees.clone()).flatten(); 255 fields.iter().map(|it| quote!(#it: self.#it.clone(), ).token_trees.clone()).flatten();
256 256
257 let list = tt::Subtree { delimiter: tt::Delimiter::Brace, token_trees: fields.collect() }; 257 let list =
258 tt::Subtree { delimiter: Some(tt::Delimiter::Brace), token_trees: fields.collect() };
258 259
259 let quoted = quote! { 260 let quoted = quote! {
260 impl Clone for #struct_name { 261 impl Clone for #struct_name {