@@ -16,7 +16,6 @@ impl<'a> StringReader<'a> {
1616 let mut tt_reader = TokenTreesReader {
1717 string_reader : self ,
1818 token : Token :: dummy ( ) ,
19- joint_to_prev : Joint ,
2019 open_braces : Vec :: new ( ) ,
2120 unmatched_braces : Vec :: new ( ) ,
2221 matching_delim_spans : Vec :: new ( ) ,
@@ -32,7 +31,6 @@ impl<'a> StringReader<'a> {
3231struct TokenTreesReader < ' a > {
3332 string_reader : StringReader < ' a > ,
3433 token : Token ,
35- joint_to_prev : IsJoint ,
3634 /// Stack of open delimiters and their spans. Used for error message.
3735 open_braces : Vec < ( token:: DelimToken , Span ) > ,
3836 unmatched_braces : Vec < UnmatchedBrace > ,
@@ -53,7 +51,7 @@ impl<'a> TokenTreesReader<'a> {
5351 fn parse_all_token_trees ( & mut self ) -> PResult < ' a , TokenStream > {
5452 let mut buf = TokenStreamBuilder :: default ( ) ;
5553
56- self . real_token ( ) ;
54+ self . bump ( ) ;
5755 while self . token != token:: Eof {
5856 buf. push ( self . parse_token_tree ( ) ?) ;
5957 }
@@ -126,7 +124,7 @@ impl<'a> TokenTreesReader<'a> {
126124
127125 // Parse the open delimiter.
128126 self . open_braces . push ( ( delim, self . token . span ) ) ;
129- self . real_token ( ) ;
127+ self . bump ( ) ;
130128
131129 // Parse the token trees within the delimiters.
132130 // We stop at any delimiter so we can try to recover if the user
@@ -171,7 +169,7 @@ impl<'a> TokenTreesReader<'a> {
171169 ) ) ;
172170 }
173171 // Parse the closing delimiter.
174- self . real_token ( ) ;
172+ self . bump ( ) ;
175173 }
176174 // Incorrect delimiter.
177175 token:: CloseDelim ( other) => {
@@ -217,7 +215,7 @@ impl<'a> TokenTreesReader<'a> {
217215 // bar(baz(
218216 // } // Incorrect delimiter but matches the earlier `{`
219217 if !self . open_braces . iter ( ) . any ( |& ( b, _) | b == other) {
220- self . real_token ( ) ;
218+ self . bump ( ) ;
221219 }
222220 }
223221 token:: Eof => {
@@ -264,17 +262,19 @@ impl<'a> TokenTreesReader<'a> {
264262 }
265263 _ => {
266264 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) )
270270 }
271271 }
272272 }
273273
274- fn real_token ( & mut self ) {
274+ fn bump ( & mut self ) -> IsJoint {
275275 let ( joint_to_prev, token) = self . string_reader . next_token ( ) ;
276- self . joint_to_prev = joint_to_prev;
277276 self . token = token;
277+ joint_to_prev
278278 }
279279}
280280
0 commit comments