-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Proposal
Problem statement
The RustcEncodable and RustcDecoadable derives serve no purpose on their own and are deprecated, undocumented, and widely unused. The derives produce code for rustc-serialize, an external crate which has not had a release since April 2017 and is officially deprecated in favor of serde.
The rustc-serialize crate will, in its current state, fail to compile at some point in the future, as it contains code with a future compatibility warning:
> warning: impl method assumes more implied bounds than the corresponding trait method
> --> /home/jhpratt/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustc-serialize-0.3.24/src/serialize.rs:1155:41
> |
> 1155 | fn decode<D: Decoder>(d: &mut D) -> Result<Cow<'static, T>, D::Error> {
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this type to make the impl signature compatible: `Result<Cow<'a, T>, <D as serialize::Decoder>::Error>`
> |
> = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
> = note: for more information, see issue #105572 <https://github.com/rust-lang/rust/issues/105572>
> = note: `#[allow(implied_bounds_entailment)]` on by default
>
Solution sketch
The RustcEncodable and RustcDecodable derives are to be soft-destabilized, as mentioned in rust-lang/rust#92594. This turns any use of them into a deny-by-default lint, which is stronger than the warn-by-default deprecation warning that is currently present.
Additionally, the RustcEncodable and RustcDecodable traits are to be removed from the standard library's preludes in all future editions (i.e. ≥2024). rustfix will change existing uses to use the path to the previous prelude.
Alternatives
A full destabilization is not proposed due to breakage of existing code. If/when rustc-serialize fails to compile on stable as mentioned above, a full destabilization would make more sense.
While this proposes both soft-destabilizing and removing the derives from the prelude, there is no reason one could not be accepted without the other if it is so desired.
Links and related work
- The derives are undocumented.
- The repository for
rustc-serializeis archived. - The similar
EncodableandDecodablederives were previously removed outright.. RustcEncodableandRustcDecodablewere deprecated in March 2021. This was uncontroversial enough that FCP was functionally skipped.- Destabilization of
RustcEncodableandRustcDecodablewas previously proposed, but closed due to inactivity.