Skip to content

Commit 049425f

Browse files
committed
remove dead code
1 parent ce438aa commit 049425f

File tree

4 files changed

+21
-90
lines changed

4 files changed

+21
-90
lines changed

crates/ra_mbe/src/lib.rs

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,13 @@
33
/// interface, although it contains some code to bridge `SyntaxNode`s and
44
/// `TokenTree`s as well!
55
6-
macro_rules! impl_froms {
7-
($e:ident: $($v:ident), *) => {
8-
$(
9-
impl From<$v> for $e {
10-
fn from(it: $v) -> $e {
11-
$e::$v(it)
12-
}
13-
}
14-
)*
15-
}
16-
}
17-
186
mod parser;
197
mod mbe_parser;
208
mod mbe_expander;
219
mod syntax_bridge;
22-
mod tt_cursor;
2310
mod tt_iter;
2411
mod subtree_source;
25-
mod subtree_parser;
2612

27-
use ra_syntax::SmolStr;
2813
use smallvec::SmallVec;
2914

3015
pub use tt::{Delimiter, Punct};
@@ -72,29 +57,6 @@ pub(crate) struct Rule {
7257
pub(crate) rhs: tt::Subtree,
7358
}
7459

75-
#[derive(Clone, Debug, PartialEq, Eq)]
76-
pub(crate) enum TokenTree {
77-
Leaf(Leaf),
78-
Subtree(Subtree),
79-
Repeat(Repeat),
80-
}
81-
impl_froms!(TokenTree: Leaf, Subtree, Repeat);
82-
83-
#[derive(Clone, Debug, PartialEq, Eq)]
84-
pub(crate) enum Leaf {
85-
Literal(Literal),
86-
Punct(Punct),
87-
Ident(Ident),
88-
Var(Var),
89-
}
90-
impl_froms!(Leaf: Literal, Punct, Ident, Var);
91-
92-
#[derive(Clone, Debug, PartialEq, Eq)]
93-
pub(crate) struct Subtree {
94-
pub(crate) delimiter: Delimiter,
95-
pub(crate) token_trees: Vec<TokenTree>,
96-
}
97-
9860
#[derive(Clone, Debug, Eq)]
9961
pub(crate) enum Separator {
10062
Literal(tt::Literal),
@@ -120,27 +82,5 @@ impl PartialEq for crate::Separator {
12082
}
12183
}
12284

123-
#[derive(Clone, Debug, PartialEq, Eq)]
124-
pub(crate) struct Repeat {
125-
pub(crate) subtree: Subtree,
126-
pub(crate) separator: Option<Separator>,
127-
}
128-
129-
#[derive(Clone, Debug, PartialEq, Eq)]
130-
pub(crate) struct Literal {
131-
pub(crate) text: SmolStr,
132-
}
133-
134-
#[derive(Clone, Debug, PartialEq, Eq)]
135-
pub(crate) struct Ident {
136-
pub(crate) text: SmolStr,
137-
}
138-
139-
#[derive(Clone, Debug, PartialEq, Eq)]
140-
pub(crate) struct Var {
141-
pub(crate) text: SmolStr,
142-
pub(crate) kind: Option<SmolStr>,
143-
}
144-
14585
#[cfg(test)]
14686
mod tests;

crates/ra_mbe/src/mbe_expander/matcher.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
use crate::{
22
mbe_expander::{Binding, Bindings, Fragment},
33
parser::{parse_pattern, Op, RepeatKind},
4-
subtree_parser::OffsetTokenSink,
54
subtree_source::SubtreeTokenSource,
65
tt_iter::TtIter,
76
ExpandError, Separator,
87
};
98

10-
use ra_parser::FragmentKind::*;
11-
use ra_syntax::SmolStr;
12-
use tt::buffer::TokenBuffer;
9+
use ra_parser::{FragmentKind::*, TreeSink};
10+
use ra_syntax::{SmolStr, SyntaxKind};
11+
use tt::buffer::{Cursor, TokenBuffer};
1312

1413
impl Bindings {
1514
fn push_optional(&mut self, name: &SmolStr) {
@@ -168,6 +167,24 @@ impl<'a> TtIter<'a> {
168167
&mut self,
169168
fragment_kind: ra_parser::FragmentKind,
170169
) -> Result<tt::TokenTree, ()> {
170+
pub(crate) struct OffsetTokenSink<'a> {
171+
pub(crate) cursor: Cursor<'a>,
172+
pub(crate) error: bool,
173+
}
174+
175+
impl<'a> TreeSink for OffsetTokenSink<'a> {
176+
fn token(&mut self, _kind: SyntaxKind, n_tokens: u8) {
177+
for _ in 0..n_tokens {
178+
self.cursor = self.cursor.bump_subtree();
179+
}
180+
}
181+
fn start_node(&mut self, _kind: SyntaxKind) {}
182+
fn finish_node(&mut self) {}
183+
fn error(&mut self, _error: ra_parser::ParseError) {
184+
self.error = true;
185+
}
186+
}
187+
171188
let buffer = TokenBuffer::new(self.inner.as_slice());
172189
let mut src = SubtreeTokenSource::new(&buffer);
173190
let mut sink = OffsetTokenSink { cursor: buffer.begin(), error: false };

crates/ra_mbe/src/subtree_parser.rs

Lines changed: 0 additions & 21 deletions
This file was deleted.

crates/ra_mbe/src/tt_cursor.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)