Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/mbe/src/token_map.rs')
-rw-r--r--crates/mbe/src/token_map.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/crates/mbe/src/token_map.rs b/crates/mbe/src/token_map.rs
index 6df3de3b3e..3e8c4b2d6d 100644
--- a/crates/mbe/src/token_map.rs
+++ b/crates/mbe/src/token_map.rs
@@ -1,5 +1,7 @@
//! Mapping between `TokenId`s and the token's position in macro definitions or inputs.
+use std::hash::Hash;
+
use parser::{SyntaxKind, T};
use syntax::{TextRange, TextSize};
@@ -24,6 +26,25 @@ impl TokenTextRange {
}
}
+#[derive(Debug, Clone, Default)]
+pub struct MappedSubTree {
+ pub tree: tt::Subtree,
+ pub map: TokenMap,
+}
+
+impl Eq for MappedSubTree {}
+impl PartialEq for MappedSubTree {
+ fn eq(&self, other: &Self) -> bool {
+ self.tree == other.tree && self.map == other.map
+ }
+}
+
+impl Hash for MappedSubTree {
+ fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
+ self.tree.hash(state);
+ }
+}
+
/// Maps `tt::TokenId` to the relative range of the original token.
#[derive(Debug, PartialEq, Eq, Clone, Default)]
pub struct TokenMap {