Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/mbe/src/syntax_bridge.rs1
-rw-r--r--crates/mbe/src/tt_iter.rs12
-rw-r--r--crates/tt/src/buffer.rs8
3 files changed, 14 insertions, 7 deletions
diff --git a/crates/mbe/src/syntax_bridge.rs b/crates/mbe/src/syntax_bridge.rs
index fbf6b53006..7fe4fcfc68 100644
--- a/crates/mbe/src/syntax_bridge.rs
+++ b/crates/mbe/src/syntax_bridge.rs
@@ -95,6 +95,7 @@ pub fn token_tree_to_syntax_node(
parser::Step::Token { kind, n_input_tokens: n_raw_tokens } => {
tree_sink.token(kind, n_raw_tokens)
}
+ parser::Step::FloatSplit { .. } => tree_sink.token(SyntaxKind::FLOAT_NUMBER, 1),
parser::Step::Enter { kind } => tree_sink.start_node(kind),
parser::Step::Exit => tree_sink.finish_node(),
parser::Step::Error { msg } => tree_sink.error(msg.to_string()),
diff --git a/crates/mbe/src/tt_iter.rs b/crates/mbe/src/tt_iter.rs
index e5f6b13722..b38243caee 100644
--- a/crates/mbe/src/tt_iter.rs
+++ b/crates/mbe/src/tt_iter.rs
@@ -140,6 +140,7 @@ impl<'a> TtIter<'a> {
let mut cursor = buffer.begin();
let mut error = false;
+ let mut float_splits = vec![];
for step in tree_traversal.iter() {
match step {
parser::Step::Token { kind, mut n_input_tokens } => {
@@ -150,6 +151,10 @@ impl<'a> TtIter<'a> {
cursor = cursor.bump_subtree();
}
}
+ parser::Step::FloatSplit { .. } => {
+ float_splits.push(cursor);
+ cursor = cursor.bump_subtree();
+ }
parser::Step::Enter { .. } | parser::Step::Exit => (),
parser::Step::Error { .. } => error = true,
}
@@ -167,18 +172,17 @@ impl<'a> TtIter<'a> {
if cursor.is_root() {
while curr != cursor {
if let Some(token) = curr.token_tree() {
- res.push(token);
+ res.push(token.cloned());
}
curr = curr.bump();
}
}
self.inner = self.inner.as_slice()[res.len()..].iter();
let res = match res.len() {
- 1 => Some(res[0].cloned()),
- 0 => None,
+ 0 | 1 => res.pop(),
_ => Some(tt::TokenTree::Subtree(tt::Subtree {
delimiter: tt::Delimiter::unspecified(),
- token_trees: res.into_iter().map(|it| it.cloned()).collect(),
+ token_trees: res,
})),
};
ExpandResult { value: res, err }
diff --git a/crates/tt/src/buffer.rs b/crates/tt/src/buffer.rs
index 4484431124..c4b455e3f1 100644
--- a/crates/tt/src/buffer.rs
+++ b/crates/tt/src/buffer.rs
@@ -16,8 +16,8 @@ enum Entry<'t, Span> {
// Mimicking types from proc-macro.
Subtree(Option<&'t TokenTree<Span>>, &'t Subtree<Span>, EntryId),
Leaf(&'t TokenTree<Span>),
- // End entries contain a pointer to the entry from the containing
- // token tree, or None if this is the outermost level.
+ /// End entries contain a pointer to the entry from the containing
+ /// token tree, or [`None`] if this is the outermost level.
End(Option<EntryPtr>),
}
@@ -226,7 +226,9 @@ impl<'a, Span> Cursor<'a, Span> {
/// a cursor into that subtree
pub fn bump_subtree(self) -> Cursor<'a, Span> {
match self.entry() {
- Some(Entry::Subtree(_, _, _)) => self.subtree().unwrap(),
+ Some(&Entry::Subtree(_, _, entry_id)) => {
+ Cursor::create(self.buffer, EntryPtr(entry_id, 0))
+ }
_ => self.bump(),
}
}