diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-11-21 16:35:26 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-11-22 18:37:14 +1100 |
| commit | 3ef9d4d0ed608b0493d66ffe8af2755529ce474c (patch) | |
| tree | ebebccdf93d6d9e71f3b352f1f519fd38aa04077 /compiler/rustc_middle/src/mir/mod.rs | |
| parent | cc4bb0de204516c2852f70df0f3849e542e2c95e (diff) | |
| download | rust-3ef9d4d0ed608b0493d66ffe8af2755529ce474c.tar.gz rust-3ef9d4d0ed608b0493d66ffe8af2755529ce474c.zip | |
Replace `custom_encodable` with `encodable`.
By default, `newtype_index!` types get a default `Encodable`/`Decodable` impl. You can opt out of this with `custom_encodable`. Opting out is the opposite to how Rust normally works with autogenerated (derived) impls. This commit inverts the behaviour, replacing `custom_encodable` with `encodable` which opts into the default `Encodable`/`Decodable` impl. Only 23 of the 59 `newtype_index!` occurrences need `encodable`. Even better, there were eight crates with a dependency on `rustc_serialize` just from unused default `Encodable`/`Decodable` impls. This commit removes that dependency from those eight crates.
Diffstat (limited to 'compiler/rustc_middle/src/mir/mod.rs')
| -rw-r--r-- | compiler/rustc_middle/src/mir/mod.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index d4778cdccf3..4e6f5c3fb4e 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -736,6 +736,7 @@ impl SourceInfo { rustc_index::newtype_index! { #[derive(HashStable)] + #[encodable] #[debug_format = "_{}"] pub struct Local { const RETURN_PLACE = 0; @@ -1171,6 +1172,7 @@ rustc_index::newtype_index! { /// [`CriticalCallEdges`]: ../../rustc_const_eval/transform/add_call_guards/enum.AddCallGuards.html#variant.CriticalCallEdges /// [guide-mir]: https://rustc-dev-guide.rust-lang.org/mir/ #[derive(HashStable)] + #[encodable] #[debug_format = "bb{}"] pub struct BasicBlock { const START_BLOCK = 0; @@ -1305,6 +1307,7 @@ impl<'tcx> BasicBlockData<'tcx> { rustc_index::newtype_index! { #[derive(HashStable)] + #[encodable] #[debug_format = "scope[{}]"] pub struct SourceScope { const OUTERMOST_SOURCE_SCOPE = 0; @@ -1533,6 +1536,7 @@ impl UserTypeProjection { rustc_index::newtype_index! { #[derive(HashStable)] + #[encodable] #[debug_format = "promoted[{}]"] pub struct Promoted {} } |
