diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-17 16:12:28 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-17 16:12:28 +0000 |
commit | 4dfd1553280887dc95cd622ec89000c7f5ec037e (patch) | |
tree | ebef32480be69fe1fad58678f8ad9ac97669453a /crates/ra_hir_expand/src/db.rs | |
parent | 64dac40a8665c851e48c50e6f778a51aeac2838e (diff) | |
parent | c8f858d04323f93a4bacb143d92c976b2bc1e179 (diff) |
Merge #2288
2288: Make shift an implementation detail of mbe r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_expand/src/db.rs')
-rw-r--r-- | crates/ra_hir_expand/src/db.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index 5eadee9c2..9de7c1ea8 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs | |||
@@ -32,10 +32,17 @@ impl TokenExpander { | |||
32 | } | 32 | } |
33 | } | 33 | } |
34 | 34 | ||
35 | pub fn shift(&self) -> u32 { | 35 | pub fn map_id_down(&self, id: tt::TokenId) -> tt::TokenId { |
36 | match self { | 36 | match self { |
37 | TokenExpander::MacroRules(it) => it.shift(), | 37 | TokenExpander::MacroRules(it) => it.map_id_down(id), |
38 | TokenExpander::Builtin(_) => 0, | 38 | TokenExpander::Builtin(..) => id, |
39 | } | ||
40 | } | ||
41 | |||
42 | pub fn map_id_up(&self, id: tt::TokenId) -> (tt::TokenId, mbe::Origin) { | ||
43 | match self { | ||
44 | TokenExpander::MacroRules(it) => it.map_id_up(id), | ||
45 | TokenExpander::Builtin(..) => (id, mbe::Origin::Def), | ||
39 | } | 46 | } |
40 | } | 47 | } |
41 | } | 48 | } |