Skip to content

Commit 93cc392

Browse files
committed
Document newtype_index attributes.
1 parent 08c99f8 commit 93cc392

File tree

1 file changed

+12
-2
lines changed
  • compiler/rustc_macros/src

1 file changed

+12
-2
lines changed

compiler/rustc_macros/src/lib.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,18 @@ pub fn symbols(input: TokenStream) -> TokenStream {
5757
/// to create/return a value.
5858
///
5959
/// Internally, the index uses a u32, so the index must not exceed
60-
/// `u32::MAX`. You can also customize things like the `Debug` impl,
61-
/// what traits are derived, and so forth via the macro.
60+
/// `u32::MAX`.
61+
///
62+
/// The impls provided by default are Clone, Copy, PartialEq, Eq, and Hash.
63+
///
64+
/// Accepted attributes for customization:
65+
/// - `#[derive(HashStable_Generic)]`/`#[derive(HashStable)]`: derives
66+
/// `HashStable`, as normal.
67+
/// - `#[encodable]`: derives `Encodable`/`Decodable`.
68+
/// - `#[orderable]`: derives `PartialOrd`/`Ord`, plus step-related methods.
69+
/// - `#[debug_format = "Foo({})"]`: derives `Debug` with particular output.
70+
/// - `#[max = 0xFFFF_FFFD]` specifies the max value, which allows niche
71+
/// optimizations. The default max value is 0xFFFF_FF00.
6272
#[proc_macro]
6373
#[allow_internal_unstable(step_trait, rustc_attrs, trusted_step, spec_option_partial_eq)]
6474
pub fn newtype_index(input: TokenStream) -> TokenStream {

0 commit comments

Comments
 (0)