diff options
| author | bors <bors@rust-lang.org> | 2022-12-20 07:27:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-12-20 07:27:01 +0000 |
| commit | eb9e5e711d3eef1998ff24ac2bc57386662652e9 (patch) | |
| tree | 10d0607d0ca60fd9f25fedfde0cf1a025b9de3b1 /compiler/rustc_span/src | |
| parent | 7f42e58effa3871dda6a41e250dea60cf88868ca (diff) | |
| parent | 8bfd6450c7b61ffee0fd7e21b538d00018a0e47e (diff) | |
| download | rust-eb9e5e711d3eef1998ff24ac2bc57386662652e9.tar.gz rust-eb9e5e711d3eef1998ff24ac2bc57386662652e9.zip | |
Auto merge of #105880 - Nilstrieb:make-newtypes-less-not-rust, r=oli-obk
Improve syntax of `newtype_index` This makes it more like proper Rust and also makes the implementation a lot simpler. Mostly just turns weird flags in the body into proper attributes. It should probably also be converted to an attribute macro instead of function-like, but that can be done in a future PR.
Diffstat (limited to 'compiler/rustc_span/src')
| -rw-r--r-- | compiler/rustc_span/src/def_id.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_span/src/hygiene.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_span/src/symbol.rs | 2 |
3 files changed, 13 insertions, 17 deletions
diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index e62ce2c266a..221f65b66e6 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -10,10 +10,9 @@ use std::fmt; use std::hash::{Hash, Hasher}; rustc_index::newtype_index! { - pub struct CrateNum { - ENCODABLE = custom - DEBUG_FORMAT = "crate{}" - } + #[custom_encodable] + #[debug_format = "crate{}"] + pub struct CrateNum {} } /// Item definitions in the currently-compiled crate would have the `CrateNum` @@ -194,13 +193,12 @@ 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) + #[debug_format = "DefIndex({})"] 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`. - const CRATE_DEF_INDEX = 0, + const CRATE_DEF_INDEX = 0; } } diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs index 038699154c7..c2d8287f243 100644 --- a/compiler/rustc_span/src/hygiene.rs +++ b/compiler/rustc_span/src/hygiene.rs @@ -61,9 +61,8 @@ pub struct SyntaxContextData { rustc_index::newtype_index! { /// A unique ID associated with a macro invocation and expansion. - pub struct ExpnIndex { - ENCODABLE = custom - } + #[custom_encodable] + pub struct ExpnIndex {} } /// A unique ID associated with a macro invocation and expansion. @@ -82,11 +81,10 @@ impl fmt::Debug for ExpnId { rustc_index::newtype_index! { /// A unique ID associated with a macro invocation and expansion. - pub struct LocalExpnId { - ENCODABLE = custom - ORD_IMPL = custom - DEBUG_FORMAT = "expn{}" - } + #[custom_encodable] + #[no_ord_impl] + #[debug_format = "expn{}"] + pub struct LocalExpnId {} } // To ensure correctness of incremental compilation, diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 9de6d9dc483..f23959b6e47 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1802,7 +1802,7 @@ impl fmt::Display for MacroRulesNormalizedIdent { pub struct Symbol(SymbolIndex); rustc_index::newtype_index! { - struct SymbolIndex { .. } + struct SymbolIndex {} } impl Symbol { |
