1
Fork 0

Make #[custom_encodable] an attribute for newtype_index

Makes the syntax a little more rusty.
This commit is contained in:
Nilstrieb 2022-12-18 21:02:14 +01:00
parent b4d739ef12
commit 88d5f7f4ce
6 changed files with 19 additions and 18 deletions

View file

@ -10,8 +10,8 @@ use std::fmt;
use std::hash::{Hash, Hasher};
rustc_index::newtype_index! {
#[custom_encodable]
pub struct CrateNum {
ENCODABLE = custom
DEBUG_FORMAT = "crate{}"
}
}
@ -194,9 +194,8 @@ rustc_index::newtype_index! {
/// A DefIndex is an index into the hir-map for a crate, identifying a
/// particular definition. It should really be considered an interned
/// shorthand for a particular DefPath.
#[custom_encodable] // (only encodable in metadata)
pub struct DefIndex {
ENCODABLE = custom // (only encodable in metadata)
DEBUG_FORMAT = "DefIndex({})",
/// The crate root is always assigned index 0 by the AST Map code,
/// thanks to `NodeCollector::new`.

View file

@ -61,8 +61,8 @@ pub struct SyntaxContextData {
rustc_index::newtype_index! {
/// A unique ID associated with a macro invocation and expansion.
#[custom_encodable]
pub struct ExpnIndex {
ENCODABLE = custom
}
}
@ -82,8 +82,8 @@ impl fmt::Debug for ExpnId {
rustc_index::newtype_index! {
/// A unique ID associated with a macro invocation and expansion.
#[custom_encodable]
pub struct LocalExpnId {
ENCODABLE = custom
ORD_IMPL = custom
DEBUG_FORMAT = "expn{}"
}