Remove MappedSubtree

This commit is contained in:
Lukas Wirth 2021-08-21 18:19:18 +02:00
parent 177c70128c
commit 5fb8c0ddfd
7 changed files with 21 additions and 41 deletions

View file

@ -69,7 +69,7 @@ pub use crate::{
parse_exprs_with_sep, parse_to_token_tree, syntax_node_to_token_tree,
token_tree_to_syntax_node,
},
token_map::{MappedSubTree, TokenMap},
token_map::TokenMap,
};
/// This struct contains AST for a single `macro_rules` definition. What might

View file

@ -5,7 +5,7 @@ use std::hash::Hash;
use parser::{SyntaxKind, T};
use syntax::{TextRange, TextSize};
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
enum TokenTextRange {
Token(TextRange),
Delimiter(TextRange),
@ -26,27 +26,8 @@ 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)]
#[derive(Debug, PartialEq, Eq, Clone, Default, Hash)]
pub struct TokenMap {
/// Maps `tt::TokenId` to the *relative* source range.
entries: Vec<(tt::TokenId, TokenTextRange)>,