@@ -83,7 +83,7 @@ impl TokenTree {
8383 }
8484
8585 pub fn joint ( self ) -> TokenStream {
86- TokenStream :: new ( vec ! [ ( self , Joint ) ] )
86+ TokenStream :: new ( vec ! [ ( self , Spacing :: Joint ) ] )
8787 }
8888
8989 pub fn token ( kind : TokenKind , span : Span ) -> TokenTree {
@@ -125,22 +125,20 @@ where
125125/// instead of a representation of the abstract syntax tree.
126126/// Today's `TokenTree`s can still contain AST via `token::Interpolated` for back-compat.
127127#[ derive( Clone , Debug , Default , Encodable , Decodable ) ]
128- pub struct TokenStream ( pub Lrc < Vec < TreeAndJoint > > ) ;
128+ pub struct TokenStream ( pub Lrc < Vec < TreeAndSpacing > > ) ;
129129
130- pub type TreeAndJoint = ( TokenTree , IsJoint ) ;
130+ pub type TreeAndSpacing = ( TokenTree , Spacing ) ;
131131
132132// `TokenStream` is used a lot. Make sure it doesn't unintentionally get bigger.
133133#[ cfg( target_arch = "x86_64" ) ]
134134rustc_data_structures:: static_assert_size!( TokenStream , 8 ) ;
135135
136136#[ derive( Clone , Copy , Debug , PartialEq , Encodable , Decodable ) ]
137- pub enum IsJoint {
137+ pub enum Spacing {
138+ Alone ,
138139 Joint ,
139- NonJoint ,
140140}
141141
142- use IsJoint :: * ;
143-
144142impl TokenStream {
145143 /// Given a `TokenStream` with a `Stream` of only two arguments, return a new `TokenStream`
146144 /// separating the two arguments with a comma for diagnostic suggestions.
@@ -153,7 +151,7 @@ impl TokenStream {
153151 let sp = match ( & ts, & next) {
154152 ( _, ( TokenTree :: Token ( Token { kind : token:: Comma , .. } ) , _) ) => continue ,
155153 (
156- ( TokenTree :: Token ( token_left) , NonJoint ) ,
154+ ( TokenTree :: Token ( token_left) , Spacing :: Alone ) ,
157155 ( TokenTree :: Token ( token_right) , _) ,
158156 ) if ( ( token_left. is_ident ( ) && !token_left. is_reserved_ident ( ) )
159157 || token_left. is_lit ( ) )
@@ -162,11 +160,11 @@ impl TokenStream {
162160 {
163161 token_left. span
164162 }
165- ( ( TokenTree :: Delimited ( sp, ..) , NonJoint ) , _) => sp. entire ( ) ,
163+ ( ( TokenTree :: Delimited ( sp, ..) , Spacing :: Alone ) , _) => sp. entire ( ) ,
166164 _ => continue ,
167165 } ;
168166 let sp = sp. shrink_to_hi ( ) ;
169- let comma = ( TokenTree :: token ( token:: Comma , sp) , NonJoint ) ;
167+ let comma = ( TokenTree :: token ( token:: Comma , sp) , Spacing :: Alone ) ;
170168 suggestion = Some ( ( pos, comma, sp) ) ;
171169 }
172170 }
@@ -184,19 +182,19 @@ impl TokenStream {
184182
185183impl From < TokenTree > for TokenStream {
186184 fn from ( tree : TokenTree ) -> TokenStream {
187- TokenStream :: new ( vec ! [ ( tree, NonJoint ) ] )
185+ TokenStream :: new ( vec ! [ ( tree, Spacing :: Alone ) ] )
188186 }
189187}
190188
191- impl From < TokenTree > for TreeAndJoint {
192- fn from ( tree : TokenTree ) -> TreeAndJoint {
193- ( tree, NonJoint )
189+ impl From < TokenTree > for TreeAndSpacing {
190+ fn from ( tree : TokenTree ) -> TreeAndSpacing {
191+ ( tree, Spacing :: Alone )
194192 }
195193}
196194
197195impl iter:: FromIterator < TokenTree > for TokenStream {
198196 fn from_iter < I : IntoIterator < Item = TokenTree > > ( iter : I ) -> Self {
199- TokenStream :: new ( iter. into_iter ( ) . map ( Into :: into) . collect :: < Vec < TreeAndJoint > > ( ) )
197+ TokenStream :: new ( iter. into_iter ( ) . map ( Into :: into) . collect :: < Vec < TreeAndSpacing > > ( ) )
200198 }
201199}
202200
@@ -209,7 +207,7 @@ impl PartialEq<TokenStream> for TokenStream {
209207}
210208
211209impl TokenStream {
212- pub fn new ( streams : Vec < TreeAndJoint > ) -> TokenStream {
210+ pub fn new ( streams : Vec < TreeAndSpacing > ) -> TokenStream {
213211 TokenStream ( Lrc :: new ( streams) )
214212 }
215213
@@ -320,11 +318,11 @@ impl TokenStreamBuilder {
320318 // If `self` is not empty and the last tree within the last stream is a
321319 // token tree marked with `Joint`...
322320 if let Some ( TokenStream ( ref mut last_stream_lrc) ) = self . 0 . last_mut ( ) {
323- if let Some ( ( TokenTree :: Token ( last_token) , Joint ) ) = last_stream_lrc. last ( ) {
321+ if let Some ( ( TokenTree :: Token ( last_token) , Spacing :: Joint ) ) = last_stream_lrc. last ( ) {
324322 // ...and `stream` is not empty and the first tree within it is
325323 // a token tree...
326324 let TokenStream ( ref mut stream_lrc) = stream;
327- if let Some ( ( TokenTree :: Token ( token) , is_joint ) ) = stream_lrc. first ( ) {
325+ if let Some ( ( TokenTree :: Token ( token) , spacing ) ) = stream_lrc. first ( ) {
328326 // ...and the two tokens can be glued together...
329327 if let Some ( glued_tok) = last_token. glue ( & token) {
330328 // ...then do so, by overwriting the last token
@@ -337,8 +335,7 @@ impl TokenStreamBuilder {
337335 // Overwrite the last token tree with the merged
338336 // token.
339337 let last_vec_mut = Lrc :: make_mut ( last_stream_lrc) ;
340- * last_vec_mut. last_mut ( ) . unwrap ( ) =
341- ( TokenTree :: Token ( glued_tok) , * is_joint) ;
338+ * last_vec_mut. last_mut ( ) . unwrap ( ) = ( TokenTree :: Token ( glued_tok) , * spacing) ;
342339
343340 // Remove the first token tree from `stream`. (This
344341 // is almost always the only tree in `stream`.)
@@ -375,7 +372,7 @@ impl Iterator for Cursor {
375372 type Item = TokenTree ;
376373
377374 fn next ( & mut self ) -> Option < TokenTree > {
378- self . next_with_joint ( ) . map ( |( tree, _) | tree)
375+ self . next_with_spacing ( ) . map ( |( tree, _) | tree)
379376 }
380377}
381378
@@ -384,7 +381,7 @@ impl Cursor {
384381 Cursor { stream, index : 0 }
385382 }
386383
387- pub fn next_with_joint ( & mut self ) -> Option < TreeAndJoint > {
384+ pub fn next_with_spacing ( & mut self ) -> Option < TreeAndSpacing > {
388385 if self . index < self . stream . len ( ) {
389386 self . index += 1 ;
390387 Some ( self . stream . 0 [ self . index - 1 ] . clone ( ) )
0 commit comments