about summary refs log tree commit diff
path: root/compiler/rustc_ast/src
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-09-28 11:20:42 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2022-10-03 11:42:21 +1100
commitbbb53bf7727f07c1ea6d7e2d36dc51fbfc6b6726 (patch)
tree8793fcfc346957d0c2c2cefebdb5244f0ada9c12 /compiler/rustc_ast/src
parent3be86e6528db24fb055530ef93c93b2a9fc9ce90 (diff)
downloadrust-bbb53bf7727f07c1ea6d7e2d36dc51fbfc6b6726.tar.gz
rust-bbb53bf7727f07c1ea6d7e2d36dc51fbfc6b6726.zip
Add comments to `Spacing`.
Diffstat (limited to 'compiler/rustc_ast/src')
-rw-r--r--compiler/rustc_ast/src/tokenstream.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs
index 824206a99d8..4d2049cbc41 100644
--- a/compiler/rustc_ast/src/tokenstream.rs
+++ b/compiler/rustc_ast/src/tokenstream.rs
@@ -304,9 +304,20 @@ pub struct AttributesData {
 #[derive(Clone, Debug, Default, Encodable, Decodable)]
 pub struct TokenStream(pub(crate) Lrc<Vec<TokenTree>>);
 
+/// Similar to `proc_macro::Spacing`, but for tokens.
+///
+/// Note that all `ast::TokenTree::Token` instances have a `Spacing`, but when
+/// we convert to `proc_macro::TokenTree` for proc macros only `Punct`
+/// `TokenTree`s have a `proc_macro::Spacing`.
 #[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable_Generic)]
 pub enum Spacing {
+    /// The token is not immediately followed by an operator token (as
+    /// determined by `Token::is_op`). E.g. a `+` token is `Alone` in `+ =`,
+    /// `+/*foo*/=`, `+ident`, and `+()`.
     Alone,
+
+    /// The token is immediately followed by an operator token. E.g. a `+`
+    /// token is `Joint` in `+=` and `++`.
     Joint,
 }