Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destabilize RustcEncodable and RustcDecodable #92594

Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
#![feature(variant_count)]
#![feature(const_array_from_ref)]
#![feature(const_slice_from_ref)]
#![feature(rustc_encodable_decodable)]
//
// Language features:
#![feature(abi_unadjusted)]
Expand Down
12 changes: 10 additions & 2 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1508,26 +1508,34 @@ pub(crate) mod builtin {

/// Unstable implementation detail of the `rustc` compiler, do not use.
#[rustc_builtin_macro]
#[stable(feature = "rust1", since = "1.0.0")]
#[allow_internal_unstable(core_intrinsics, libstd_sys_internals)]
#[rustc_deprecated(
since = "1.52.0",
reason = "rustc-serialize is deprecated and no longer supported"
)]
#[doc(hidden)] // While technically stable, using it is unstable, and deprecated. Hide it.
#[unstable(
feature = "rustc_encodable_decodable",
issue = "none",
reason = "RustcDecodable cannot be used stably"
)]
pub macro RustcDecodable($item:item) {
/* compiler built-in */
}

/// Unstable implementation detail of the `rustc` compiler, do not use.
#[rustc_builtin_macro]
#[stable(feature = "rust1", since = "1.0.0")]
#[allow_internal_unstable(core_intrinsics)]
#[rustc_deprecated(
since = "1.52.0",
reason = "rustc-serialize is deprecated and no longer supported"
)]
#[doc(hidden)] // While technically stable, using it is unstable, and deprecated. Hide it.
#[unstable(
feature = "rustc_encodable_decodable",
issue = "none",
reason = "RustcDecodable cannot be used stably"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
reason = "RustcDecodable cannot be used stably"
reason = "unstable implementation detail of the `rustc` compiler, do not use"

)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can mark both macros as soft-unstable (see macro bench for an example), then the instability will be reported as a deny-by-default lint and won't break other crates depending on crates using these macros.

pub macro RustcEncodable($item:item) {
/* compiler built-in */
}
Expand Down
1 change: 1 addition & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@
#![feature(ptr_internals)]
#![feature(rustc_attrs)]
#![feature(rustc_private)]
#![feature(rustc_encodable_decodable)]
#![feature(saturating_int_impl)]
#![feature(slice_concat_ext)]
#![feature(slice_internals)]
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/prelude/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub use core::prelude::v1::{
pub use core::prelude::v1::concat_bytes;

// Do not `doc(inline)` these `doc(hidden)` items.
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
#[unstable(feature = "rustc_encodable_decodable", issue = "none")]
#[allow(deprecated)]
pub use core::prelude::v1::{RustcDecodable, RustcEncodable};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a similar reexport in library/core/src/prelude/v1.rs that also needs to be marked as unstable.


Expand Down
6 changes: 3 additions & 3 deletions src/test/run-make-fulldeps/pretty-expanded/input.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[crate_type="lib"]

// #13544
// FIXME: This should be replaced with some other derive macro
#![feature(rustc_encodable_decodable)]
#[crate_type="lib"] // Why is this an outer attribute?
Copy link
Member

@camelid camelid Jan 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what the comment is about, but this should be:

Suggested change
#[crate_type="lib"] // Why is this an outer attribute?
#![crate_type="lib"]

EDIT: Ah, I see, the attribute was pre-existing. Strange. Not sure what it's for then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is because the #[crate_type="lib"] line appears in the original version of the test, so I inserted a comment questioning it. It caused my first attempt to fix the test to fail because I saw only the attribute itself and not the relatively insignficant ! when I added the #![feature(rustc_encodale_decodable)] line.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's quite strange. I bet the #[ version of the attribute does nothing, and rustc is just not warning about it.


extern crate rustc_serialize;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can likely swap this test out for derive(Debug) which'll make it simpler and drop the soft-deprecated feature use.


Expand Down