mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
mbe: split Op::Leaf
and handle multi-character puncts
This commit is contained in:
parent
47c6c8e2f3
commit
ec7148b091
6 changed files with 183 additions and 56 deletions
|
@ -88,6 +88,10 @@ impl<'a> TtIter<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns consecutive `Punct`s that can be glued together.
|
||||
///
|
||||
/// This method currently may return a single quotation, which is part of lifetime ident and
|
||||
/// conceptually not a punct in the context of mbe. Callers should handle this.
|
||||
pub(crate) fn expect_glued_punct(&mut self) -> Result<SmallVec<[tt::Punct; 3]>, ()> {
|
||||
let tt::TokenTree::Leaf(tt::Leaf::Punct(first)) = self.next().ok_or(())?.clone() else {
|
||||
return Err(());
|
||||
|
@ -182,7 +186,7 @@ impl<'a> TtIter<'a> {
|
|||
ExpandResult { value: res, err }
|
||||
}
|
||||
|
||||
pub(crate) fn peek_n(&self, n: usize) -> Option<&tt::TokenTree> {
|
||||
pub(crate) fn peek_n(&self, n: usize) -> Option<&'a tt::TokenTree> {
|
||||
self.inner.as_slice().get(n)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue