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

Soft-destabilize RustcEncodable & RustcDecodable, remove from prelude in next edition #116016

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
20 changes: 14 additions & 6 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1726,20 +1726,28 @@ pub(crate) mod builtin {
builtin # deref($pat)
}

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

/// Unstable implementation detail of the `rustc` compiler, do not use.
/// Derive macro for `rustc-serialize`. Should not be used in new code.
#[rustc_builtin_macro]
#[stable(feature = "rust1", since = "1.0.0")]
#[allow_internal_unstable(core_intrinsics, rt)]
#[unstable(
feature = "rustc_encodable_decodable",
issue = "none",
soft,
reason = "derive macro for `rustc-serialize`; should not be used in new code"
)]
#[deprecated(since = "1.52.0", note = "rustc-serialize is deprecated and no longer supported")]
#[doc(hidden)] // While technically stable, using it is unstable, and deprecated. Hide it.
pub macro RustcEncodable($item:item) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
//! The first version of the core prelude.
//! Items common to the prelude of all editions.
//!
//! See the [module-level documentation](super) for more.

#![stable(feature = "core_prelude", since = "1.4.0")]

// Re-exported core operators
#[stable(feature = "core_prelude", since = "1.4.0")]
#[doc(no_inline)]
Expand Down Expand Up @@ -68,11 +66,6 @@ pub use crate::{
#[doc(no_inline)]
pub use crate::concat_bytes;

// Do not `doc(inline)` these `doc(hidden)` items.
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
#[allow(deprecated)]
pub use crate::macros::builtin::{RustcDecodable, RustcEncodable};

// Do not `doc(no_inline)` so that they become doc items on their own
// (no public module for them to be re-exported from).
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
Expand Down
34 changes: 30 additions & 4 deletions library/core/src/prelude/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,26 @@

#![stable(feature = "core_prelude", since = "1.4.0")]

pub mod v1;
mod common;

/// The first version of the prelude of The Rust Standard Library.
///
/// See the [module-level documentation](self) for more.
#[stable(feature = "rust1", since = "1.0.0")]
pub mod v1 {
#[stable(feature = "rust1", since = "1.0.0")]
pub use super::common::*;

// Do not `doc(inline)` these `doc(hidden)` items.
#[unstable(
feature = "rustc_encodable_decodable",
issue = "none",
soft,
reason = "derive macro for `rustc-serialize`; should not be used in new code"
)]
#[allow(deprecated)]
pub use crate::macros::builtin::{RustcDecodable, RustcEncodable};
}

/// The 2015 version of the core prelude.
///
Expand Down Expand Up @@ -46,14 +65,21 @@ pub mod rust_2021 {
pub use crate::convert::{TryFrom, TryInto};
}

/// The 2024 edition of the core prelude.
/// The 2024 version of the core prelude.
///
/// See the [module-level documentation](self) for more.
#[unstable(feature = "prelude_2024", issue = "121042")]
pub mod rust_2024 {
#[unstable(feature = "prelude_2024", issue = "121042")]
#[stable(feature = "rust1", since = "1.0.0")]
pub use super::common::*;
jhpratt marked this conversation as resolved.
Show resolved Hide resolved

#[stable(feature = "prelude_2021", since = "1.55.0")]
#[doc(no_inline)]
pub use crate::iter::FromIterator;

#[stable(feature = "prelude_2021", since = "1.55.0")]
#[doc(no_inline)]
pub use super::rust_2021::*;
pub use crate::convert::{TryFrom, TryInto};

#[unstable(feature = "prelude_2024", issue = "121042")]
#[doc(no_inline)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
//! The first version of the prelude of The Rust Standard Library.
//! Items common to the prelude of all editions.
//!
//! See the [module-level documentation](super) for more.

#![stable(feature = "rust1", since = "1.0.0")]

// Re-exported core operators
#[stable(feature = "rust1", since = "1.0.0")]
#[doc(no_inline)]
Expand Down Expand Up @@ -52,11 +50,6 @@ pub use core::prelude::v1::{
#[doc(no_inline)]
pub use core::prelude::v1::concat_bytes;

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

// Do not `doc(no_inline)` so that they become doc items on their own
// (no public module for them to be re-exported from).
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
Expand Down
26 changes: 22 additions & 4 deletions library/std/src/prelude/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,26 @@

#![stable(feature = "rust1", since = "1.0.0")]

pub mod v1;
mod common;

/// The first version of the prelude of The Rust Standard Library.
///
/// See the [module-level documentation](self) for more.
#[stable(feature = "rust1", since = "1.0.0")]
pub mod v1 {
#[stable(feature = "rust1", since = "1.0.0")]
pub use super::common::*;

// Do not `doc(inline)` these `doc(hidden)` items.
#[unstable(
feature = "rustc_encodable_decodable",
issue = "none",
soft,
reason = "derive macro for `rustc-serialize`; should not be used in new code"
)]
#[allow(deprecated)]
pub use core::prelude::v1::{RustcDecodable, RustcEncodable};
}

/// The 2015 version of the prelude of The Rust Standard Library.
///
Expand Down Expand Up @@ -134,9 +153,8 @@ pub mod rust_2021 {
/// See the [module-level documentation](self) for more.
#[unstable(feature = "prelude_2024", issue = "121042")]
pub mod rust_2024 {
#[unstable(feature = "prelude_2024", issue = "121042")]
#[doc(no_inline)]
pub use super::v1::*;
#[stable(feature = "rust1", since = "1.0.0")]
pub use super::common::*;

#[unstable(feature = "prelude_2024", issue = "121042")]
#[doc(no_inline)]
Expand Down
16 changes: 6 additions & 10 deletions tests/run-make-fulldeps/pretty-expanded/input.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#[crate_type="lib"]

// #13544

extern crate rustc_serialize;

#[derive(RustcEncodable)] pub struct A;
#[derive(RustcEncodable)] pub struct B(isize);
#[derive(RustcEncodable)] pub struct C { x: isize }
#[derive(RustcEncodable)] pub enum D {}
#[derive(RustcEncodable)] pub enum E { y }
#[derive(RustcEncodable)] pub enum F { z(isize) }
#[derive(Debug)] pub struct A;
#[derive(Debug)] pub struct B(isize);
#[derive(Debug)] pub struct C { x: isize }
#[derive(Debug)] pub enum D {}
#[derive(Debug)] pub enum E { y }
#[derive(Debug)] pub enum F { z(isize) }
16 changes: 16 additions & 0 deletions tests/ui/feature-gates/feature-gate-rustc_encodable_decodable.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#![crate_type = "lib"]

// This isn't intended to compile, so it's easiest to just ignore this error.
extern crate rustc_serialize; //~ERROR can't find crate for `rustc_serialize`

#[derive(
RustcEncodable,
//~^ ERROR use of unstable library feature 'rustc_encodable_decodable'
//~^^ WARNING this was previously accepted by the compiler
//~^^^ WARNING use of deprecated macro `RustcEncodable`
RustcDecodable,
//~^ ERROR use of unstable library feature 'rustc_encodable_decodable'
//~^^ WARNING this was previously accepted by the compiler
//~^^^ WARNING use of deprecated macro `RustcDecodable`
)]
struct S;
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
error[E0463]: can't find crate for `rustc_serialize`
--> $DIR/feature-gate-rustc_encodable_decodable.rs:4:1
|
LL | extern crate rustc_serialize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
|
= help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

error: use of unstable library feature 'rustc_encodable_decodable': derive macro for `rustc-serialize`; should not be used in new code
--> $DIR/feature-gate-rustc_encodable_decodable.rs:7:5
|
LL | RustcEncodable,
| ^^^^^^^^^^^^^^
|
= 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 #64266 <https://github.com/rust-lang/rust/issues/64266>
jhpratt marked this conversation as resolved.
Show resolved Hide resolved
= note: `#[deny(soft_unstable)]` on by default

warning: use of deprecated macro `RustcEncodable`: rustc-serialize is deprecated and no longer supported
--> $DIR/feature-gate-rustc_encodable_decodable.rs:7:5
|
LL | RustcEncodable,
| ^^^^^^^^^^^^^^
|
= note: `#[warn(deprecated)]` on by default

error: use of unstable library feature 'rustc_encodable_decodable': derive macro for `rustc-serialize`; should not be used in new code
--> $DIR/feature-gate-rustc_encodable_decodable.rs:11:5
|
LL | RustcDecodable,
| ^^^^^^^^^^^^^^
|
= 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 #64266 <https://github.com/rust-lang/rust/issues/64266>
Copy link
Member

Choose a reason for hiding this comment

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

Would it be worth making this warning show up in cargo's future-compat reports? Not all future-compat warnings show up there, unfortunately. It needs to have reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow. Maybe soft_unstable should get that flag?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that would be worthwhile, but in a separate PR as it's only tangentially related to this.


warning: use of deprecated macro `RustcDecodable`: rustc-serialize is deprecated and no longer supported
--> $DIR/feature-gate-rustc_encodable_decodable.rs:11:5
|
LL | RustcDecodable,
| ^^^^^^^^^^^^^^

error: aborting due to 3 previous errors; 2 warnings emitted

For more information about this error, try `rustc --explain E0463`.
Future incompatibility report: Future breakage diagnostic:
error: use of unstable library feature 'rustc_encodable_decodable': derive macro for `rustc-serialize`; should not be used in new code
--> $DIR/feature-gate-rustc_encodable_decodable.rs:7:5
|
LL | RustcEncodable,
| ^^^^^^^^^^^^^^
|
= 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 #64266 <https://github.com/rust-lang/rust/issues/64266>
= note: `#[deny(soft_unstable)]` on by default

Future breakage diagnostic:
error: use of unstable library feature 'rustc_encodable_decodable': derive macro for `rustc-serialize`; should not be used in new code
--> $DIR/feature-gate-rustc_encodable_decodable.rs:11:5
|
LL | RustcDecodable,
| ^^^^^^^^^^^^^^
|
= 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 #64266 <https://github.com/rust-lang/rust/issues/64266>
= note: `#[deny(soft_unstable)]` on by default

Loading