Refactor token collection to capture trailing token immediately
This commit is contained in:
parent
dc1eee2f25
commit
ccfc292999
5 changed files with 124 additions and 118 deletions
|
@ -127,14 +127,10 @@ where
|
|||
}
|
||||
|
||||
pub trait CreateTokenStream: sync::Send + sync::Sync {
|
||||
fn add_trailing_semi(&self) -> Box<dyn CreateTokenStream>;
|
||||
fn create_token_stream(&self) -> TokenStream;
|
||||
}
|
||||
|
||||
impl CreateTokenStream for TokenStream {
|
||||
fn add_trailing_semi(&self) -> Box<dyn CreateTokenStream> {
|
||||
panic!("Cannot call `add_trailing_semi` on a `TokenStream`!");
|
||||
}
|
||||
fn create_token_stream(&self) -> TokenStream {
|
||||
self.clone()
|
||||
}
|
||||
|
@ -151,13 +147,6 @@ impl LazyTokenStream {
|
|||
LazyTokenStream(Lrc::new(Box::new(inner)))
|
||||
}
|
||||
|
||||
/// Extends the captured stream by one token,
|
||||
/// which must be a trailing semicolon. This
|
||||
/// affects the `TokenStream` created by `make_tokenstream`.
|
||||
pub fn add_trailing_semi(&self) -> LazyTokenStream {
|
||||
LazyTokenStream(Lrc::new(self.0.add_trailing_semi()))
|
||||
}
|
||||
|
||||
pub fn create_token_stream(&self) -> TokenStream {
|
||||
self.0.create_token_stream()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue