File tree Expand file tree Collapse file tree 2 files changed +6
-11
lines changed Expand file tree Collapse file tree 2 files changed +6
-11
lines changed Original file line number Diff line number Diff line change 1
- use crate :: parse:: { token_stream , Cursor } ;
1
+ use crate :: parse:: { self , Cursor } ;
2
2
use crate :: { Delimiter , Spacing , TokenTree } ;
3
3
#[ cfg( span_locations) ]
4
4
use std:: cell:: RefCell ;
@@ -139,12 +139,7 @@ impl FromStr for TokenStream {
139
139
// Create a dummy file & add it to the source map
140
140
let cursor = get_cursor ( src) ;
141
141
142
- let ( rest, tokens) = token_stream ( cursor) ?;
143
- if rest. is_empty ( ) {
144
- Ok ( tokens)
145
- } else {
146
- Err ( LexError )
147
- }
142
+ parse:: token_stream ( cursor)
148
143
}
149
144
}
150
145
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ impl<'a> Cursor<'a> {
26
26
self . rest . starts_with ( s)
27
27
}
28
28
29
- pub ( crate ) fn is_empty ( & self ) -> bool {
29
+ fn is_empty ( & self ) -> bool {
30
30
self . rest . is_empty ( )
31
31
}
32
32
@@ -148,7 +148,7 @@ fn word_break(input: Cursor) -> Result<Cursor, LexError> {
148
148
}
149
149
}
150
150
151
- pub ( crate ) fn token_stream ( mut input : Cursor ) -> PResult < TokenStream > {
151
+ pub ( crate ) fn token_stream ( mut input : Cursor ) -> Result < TokenStream , LexError > {
152
152
let mut trees = Vec :: new ( ) ;
153
153
let mut stack = Vec :: new ( ) ;
154
154
@@ -217,8 +217,8 @@ pub(crate) fn token_stream(mut input: Cursor) -> PResult<TokenStream> {
217
217
}
218
218
}
219
219
220
- if stack. is_empty ( ) {
221
- Ok ( ( input , TokenStream { inner : trees } ) )
220
+ if stack. is_empty ( ) && input . is_empty ( ) {
221
+ Ok ( TokenStream { inner : trees } )
222
222
} else {
223
223
Err ( LexError )
224
224
}
You can’t perform that action at this time.
0 commit comments