@@ -16,7 +16,6 @@ impl<'a> StringReader<'a> {
16
16
let mut tt_reader = TokenTreesReader {
17
17
string_reader : self ,
18
18
token : Token :: dummy ( ) ,
19
- joint_to_prev : Joint ,
20
19
open_braces : Vec :: new ( ) ,
21
20
unmatched_braces : Vec :: new ( ) ,
22
21
matching_delim_spans : Vec :: new ( ) ,
@@ -32,7 +31,6 @@ impl<'a> StringReader<'a> {
32
31
struct TokenTreesReader < ' a > {
33
32
string_reader : StringReader < ' a > ,
34
33
token : Token ,
35
- joint_to_prev : IsJoint ,
36
34
/// Stack of open delimiters and their spans. Used for error message.
37
35
open_braces : Vec < ( token:: DelimToken , Span ) > ,
38
36
unmatched_braces : Vec < UnmatchedBrace > ,
@@ -53,7 +51,7 @@ impl<'a> TokenTreesReader<'a> {
53
51
fn parse_all_token_trees ( & mut self ) -> PResult < ' a , TokenStream > {
54
52
let mut buf = TokenStreamBuilder :: default ( ) ;
55
53
56
- self . real_token ( ) ;
54
+ self . bump ( ) ;
57
55
while self . token != token:: Eof {
58
56
buf. push ( self . parse_token_tree ( ) ?) ;
59
57
}
@@ -126,7 +124,7 @@ impl<'a> TokenTreesReader<'a> {
126
124
127
125
// Parse the open delimiter.
128
126
self . open_braces . push ( ( delim, self . token . span ) ) ;
129
- self . real_token ( ) ;
127
+ self . bump ( ) ;
130
128
131
129
// Parse the token trees within the delimiters.
132
130
// We stop at any delimiter so we can try to recover if the user
@@ -171,7 +169,7 @@ impl<'a> TokenTreesReader<'a> {
171
169
) ) ;
172
170
}
173
171
// Parse the closing delimiter.
174
- self . real_token ( ) ;
172
+ self . bump ( ) ;
175
173
}
176
174
// Incorrect delimiter.
177
175
token:: CloseDelim ( other) => {
@@ -217,7 +215,7 @@ impl<'a> TokenTreesReader<'a> {
217
215
// bar(baz(
218
216
// } // Incorrect delimiter but matches the earlier `{`
219
217
if !self . open_braces . iter ( ) . any ( |& ( b, _) | b == other) {
220
- self . real_token ( ) ;
218
+ self . bump ( ) ;
221
219
}
222
220
}
223
221
token:: Eof => {
@@ -264,17 +262,19 @@ impl<'a> TokenTreesReader<'a> {
264
262
}
265
263
_ => {
266
264
let tt = TokenTree :: Token ( self . token . take ( ) ) ;
267
- self . real_token ( ) ;
268
- let is_joint = self . joint_to_prev == Joint && self . token . is_op ( ) ;
269
- Ok ( ( tt, if is_joint { Joint } else { NonJoint } ) )
265
+ let mut is_joint = self . bump ( ) ;
266
+ if !self . token . is_op ( ) {
267
+ is_joint = NonJoint ;
268
+ }
269
+ Ok ( ( tt, is_joint) )
270
270
}
271
271
}
272
272
}
273
273
274
- fn real_token ( & mut self ) {
274
+ fn bump ( & mut self ) -> IsJoint {
275
275
let ( joint_to_prev, token) = self . string_reader . next_token ( ) ;
276
- self . joint_to_prev = joint_to_prev;
277
276
self . token = token;
277
+ joint_to_prev
278
278
}
279
279
}
280
280
0 commit comments