// they are treated specially by the `def_path` function.
/// The crate root (marker)
CrateRoot,
- // Catch-all for random DefId things like DUMMY_NODE_ID
+ // Catch-all for random DefId things like `DUMMY_NODE_ID`
Misc,
// Different kinds of items and item-like things:
/// An impl
AnonConst,
/// An `impl Trait` type node
ImplTrait,
- /// GlobalMetaData identifies a piece of crate metadata that is global to
- /// a whole crate (as opposed to just one item). GlobalMetaData components
- /// are only supposed to show up right below the crate root.
+ /// Identifies a piece of crate metadata that is global to a whole crate
+ /// (as opposed to just one item). `GlobalMetaData` components are only
+ /// supposed to show up right below the crate root.
GlobalMetaData(InternedString),
}
}
}
+/// Evaluates to the number of tokens passed to it.
+///
+/// Logarithmic counting: every one or two recursive expansions, the number of
+/// tokens to count is divided by two, instead of being reduced by one.
+/// Therefore, the recursion depth is the binary logarithm of the number of
+/// tokens to count, and the expanded tree is likewise very small.
macro_rules! count {
- () => (0usize);
- ( $x:tt $($xs:tt)* ) => (1usize + count!($($xs)*));
+ () => (0usize);
+ ($one:tt) => (1usize);
+ ($($pairs:tt $_p:tt)*) => (count!($($pairs)*) << 1usize);
+ ($odd:tt $($rest:tt)*) => (count!($($rest)*) | 1usize);
}
// We define the GlobalMetaDataKind enum with this macro because we want to