diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-12-18 11:47:50 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-12-18 11:47:50 +0000 |
commit | 242f0ae1d8e6766091a6050431c3d417a43a2a3e (patch) | |
tree | b45d7619b97cc6edaf6bcf7d1a42366879bdd703 /crates/ra_hir_expand/src/builtin_derive.rs | |
parent | 46ca40ccfced6945e05a25979a2703ad967d2fe0 (diff) | |
parent | 41544a40883874553f570e2999bf56d172bd6246 (diff) |
Merge #2545
2545: Add Token id to all tt::TokenTree r=matklad a=edwin0cheng
This PR try to add token id to all `tt::Leaf` and `tt::Delimiter`.
~~Some tests are failed now because of #2544~~
~~Still blocked by a test in goto-definition : see https://github.com/rust-analyzer/rust-analyzer/pull/2544#issuecomment-565572553~~
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir_expand/src/builtin_derive.rs')
-rw-r--r-- | crates/ra_hir_expand/src/builtin_derive.rs | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs index b26441253..62c60e336 100644 --- a/crates/ra_hir_expand/src/builtin_derive.rs +++ b/crates/ra_hir_expand/src/builtin_derive.rs | |||
@@ -97,11 +97,24 @@ fn parse_adt(tt: &tt::Subtree) -> Result<BasicAdtInfo, mbe::ExpandError> { | |||
97 | 97 | ||
98 | fn make_type_args(n: usize, bound: Vec<tt::TokenTree>) -> Vec<tt::TokenTree> { | 98 | fn make_type_args(n: usize, bound: Vec<tt::TokenTree>) -> Vec<tt::TokenTree> { |
99 | let mut result = Vec::<tt::TokenTree>::new(); | 99 | let mut result = Vec::<tt::TokenTree>::new(); |
100 | result.push(tt::Leaf::Punct(tt::Punct { char: '<', spacing: tt::Spacing::Alone }).into()); | 100 | result.push( |
101 | tt::Leaf::Punct(tt::Punct { | ||
102 | char: '<', | ||
103 | spacing: tt::Spacing::Alone, | ||
104 | id: tt::TokenId::unspecified(), | ||
105 | }) | ||
106 | .into(), | ||
107 | ); | ||
101 | for i in 0..n { | 108 | for i in 0..n { |
102 | if i > 0 { | 109 | if i > 0 { |
103 | result | 110 | result.push( |
104 | .push(tt::Leaf::Punct(tt::Punct { char: ',', spacing: tt::Spacing::Alone }).into()); | 111 | tt::Leaf::Punct(tt::Punct { |
112 | char: ',', | ||
113 | spacing: tt::Spacing::Alone, | ||
114 | id: tt::TokenId::unspecified(), | ||
115 | }) | ||
116 | .into(), | ||
117 | ); | ||
105 | } | 118 | } |
106 | result.push( | 119 | result.push( |
107 | tt::Leaf::Ident(tt::Ident { | 120 | tt::Leaf::Ident(tt::Ident { |
@@ -112,7 +125,14 @@ fn make_type_args(n: usize, bound: Vec<tt::TokenTree>) -> Vec<tt::TokenTree> { | |||
112 | ); | 125 | ); |
113 | result.extend(bound.iter().cloned()); | 126 | result.extend(bound.iter().cloned()); |
114 | } | 127 | } |
115 | result.push(tt::Leaf::Punct(tt::Punct { char: '>', spacing: tt::Spacing::Alone }).into()); | 128 | result.push( |
129 | tt::Leaf::Punct(tt::Punct { | ||
130 | char: '>', | ||
131 | spacing: tt::Spacing::Alone, | ||
132 | id: tt::TokenId::unspecified(), | ||
133 | }) | ||
134 | .into(), | ||
135 | ); | ||
116 | result | 136 | result |
117 | } | 137 | } |
118 | 138 | ||