Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/mbe/src/tt_iter.rs')
-rw-r--r--crates/mbe/src/tt_iter.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/crates/mbe/src/tt_iter.rs b/crates/mbe/src/tt_iter.rs
index 40e8a2385f..71513ef439 100644
--- a/crates/mbe/src/tt_iter.rs
+++ b/crates/mbe/src/tt_iter.rs
@@ -51,6 +51,13 @@ impl<'a, S: Span> TtIter<'a, S> {
}
}
+ pub(crate) fn expect_dollar(&mut self) -> Result<(), ()> {
+ match self.expect_leaf()? {
+ tt::Leaf::Punct(tt::Punct { char: '$', .. }) => Ok(()),
+ _ => Err(()),
+ }
+ }
+
pub(crate) fn expect_ident(&mut self) -> Result<&'a tt::Ident<S>, ()> {
match self.expect_leaf()? {
tt::Leaf::Ident(it) if it.text != "_" => Ok(it),
@@ -169,10 +176,10 @@ impl<'a, S: Span> TtIter<'a, S> {
}
self.inner = self.inner.as_slice()[res.len()..].iter();
- let res = match res.len() {
- 0 | 1 => res.pop(),
- _ => Some(tt::TokenTree::Subtree(tt::Subtree {
- delimiter: tt::Delimiter::DUMMY_INVISIBLE,
+ let res = match &*res {
+ [] | [_] => res.pop(),
+ [first, ..] => Some(tt::TokenTree::Subtree(tt::Subtree {
+ delimiter: tt::Delimiter::invisible_spanned(first.first_span()),
token_trees: res,
})),
};