Skip to content

Commit bbb53bf

Browse files
committed
Add comments to Spacing.
1 parent 3be86e6 commit bbb53bf

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

compiler/rustc_ast/src/tokenstream.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,20 @@ pub struct AttributesData {
304304
#[derive(Clone, Debug, Default, Encodable, Decodable)]
305305
pub struct TokenStream(pub(crate) Lrc<Vec<TokenTree>>);
306306

307+
/// Similar to `proc_macro::Spacing`, but for tokens.
308+
///
309+
/// Note that all `ast::TokenTree::Token` instances have a `Spacing`, but when
310+
/// we convert to `proc_macro::TokenTree` for proc macros only `Punct`
311+
/// `TokenTree`s have a `proc_macro::Spacing`.
307312
#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable_Generic)]
308313
pub enum Spacing {
314+
/// The token is not immediately followed by an operator token (as
315+
/// determined by `Token::is_op`). E.g. a `+` token is `Alone` in `+ =`,
316+
/// `+/*foo*/=`, `+ident`, and `+()`.
309317
Alone,
318+
319+
/// The token is immediately followed by an operator token. E.g. a `+`
320+
/// token is `Joint` in `+=` and `++`.
310321
Joint,
311322
}
312323

0 commit comments

Comments
 (0)