diff options
| author | bors <bors@rust-lang.org> | 2020-08-15 00:45:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-08-15 00:45:13 +0000 |
| commit | 668a34e0f438d4a950b9440239656d6755ad963c (patch) | |
| tree | 1ef1c77cb067c89cfca1b41644d5335e673b30fb /src/test/rustdoc-ui/coverage/json.rs | |
| parent | 95879ad96104afa584e7aec7806cec1d0bd84116 (diff) | |
| parent | c4f91bb28102e88d4ab94e8d3b2dbc25e02dfa53 (diff) | |
| download | rust-668a34e0f438d4a950b9440239656d6755ad963c.tar.gz rust-668a34e0f438d4a950b9440239656d6755ad963c.zip | |
Auto merge of #73851 - matthewjasper:serialize-not-special, r=oli-obk
Remove most specialization use in serialization
Switching from specialization to min_specialization in the compiler made the unsoundness of how we used these traits pretty clear. This changes how the `Encodable` and `Decodable` traits work to be more friendly for types need a `TyCtxt` to deserialize.
The alternative design of having both `Encodable` and `TyEncodable` traits was considered, but doesn't really work because the following impls would conflict:
```
impl<E: Ecodable> TyEncodable for Encodable
impl<E: TyEcodable> TyEncodable for [E]
```
## How-to guide
- `Rustc(De|En)codable` is now spelled `Ty(De|En)coable` in `rustc_middle`, `Metadata(En|De)codable` in `rustc_metadata` where needed, and `(De|En)codable` everywhere else.
- Manual implementations of `(De|En)codable` shouldn't be much different.
- If you're adding a new interned type that needs to be en/decodable then the simplest thing way to handle this is:
- Have the type be a wrapper around a reference to the interned data (i.e. do what `ty::Predicate` does, and not what all of the other interned types do)
- Derive `Ty(En|De)codable` on the inner type
- Implement `Encodable<impl TyEncoder>` by forwarding to the inner type.
- Implement `Decodable<impl TyDecoder>` by decoding the inner type and then creating the wrapper around that (using the `tcx` from the decoder as needed).
cc @rust-lang/compiler for opinions on this change
r? @oli-obk
Diffstat (limited to 'src/test/rustdoc-ui/coverage/json.rs')
0 files changed, 0 insertions, 0 deletions
