Skip to content

Commit e55e28b

Browse files
committed
Document newtype_index attributes.
1 parent 587a542 commit e55e28b

File tree

1 file changed

+13
-2
lines changed
  • compiler/rustc_index_macros/src

1 file changed

+13
-2
lines changed

compiler/rustc_index_macros/src/lib.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,19 @@ mod newtype;
1818
/// to create/return a value.
1919
///
2020
/// Internally, the index uses a u32, so the index must not exceed
21-
/// `u32::MAX`. You can also customize things like the `Debug` impl,
22-
/// what traits are derived, and so forth via the macro.
21+
/// `u32::MAX`.
22+
///
23+
/// The impls provided by default are Clone, Copy, PartialEq, Eq, and Hash.
24+
///
25+
/// Accepted attributes for customization:
26+
/// - #[derive(HashStable_Generic)]/#[derive(HashStable)]: derives
27+
/// `HashStable`, as normal.
28+
/// - #[encodable]: derives `Encodable`/`Decodable`.
29+
/// - #[orderable]: derives `PartialOrd`/`Ord`, plus step-related methods.
30+
/// - #[debug_format = "Foo({})"]: derives `Debug` with particular output.
31+
/// - #[max = 0xFFFF_FFFD]: specifies the max value, which allows niche
32+
/// optimizations. The default max value is 0xFFFF_FF00.
33+
/// - #[gate_rustc_only]: makes parts of the generated code nightly-only.
2334
#[proc_macro]
2435
#[cfg_attr(
2536
feature = "nightly",

0 commit comments

Comments
 (0)