Skip to content

Commit 7114443

Browse files
committed
Auto merge of rust-lang#116016 - jhpratt:kill-rustc-serialize, r=ehuss
Soft-destabilize `RustcEncodable` & `RustcDecodable`, remove from prelude in next edition cc rust-lang/libs-team#272 Any use of `RustcEncodable` and `RustcDecodable` now triggers a deny-by-default lint. The derives have been removed from the 2024 prelude. I specifically chose **not** to document this in the module-level documentation, as the presence in existing preludes is not documented (which I presume is intentional). This does not implement the proposed change for `rustfix`, which I will be looking into shortly. With regard to the items in the preludes being stable, this should not be an issue because rust-lang#15702 has been resolved. r? libs-api
2 parents 78f45f3 + fc53982 commit 7114443

File tree

5 files changed

+68
-30
lines changed

5 files changed

+68
-30
lines changed

core/src/macros/mod.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,20 +1726,28 @@ pub(crate) mod builtin {
17261726
builtin # deref($pat)
17271727
}
17281728

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

1739-
/// Unstable implementation detail of the `rustc` compiler, do not use.
1743+
/// Derive macro for `rustc-serialize`. Should not be used in new code.
17401744
#[rustc_builtin_macro]
1741-
#[stable(feature = "rust1", since = "1.0.0")]
1742-
#[allow_internal_unstable(core_intrinsics, rt)]
1745+
#[unstable(
1746+
feature = "rustc_encodable_decodable",
1747+
issue = "none",
1748+
soft,
1749+
reason = "derive macro for `rustc-serialize`; should not be used in new code"
1750+
)]
17431751
#[deprecated(since = "1.52.0", note = "rustc-serialize is deprecated and no longer supported")]
17441752
#[doc(hidden)] // While technically stable, using it is unstable, and deprecated. Hide it.
17451753
pub macro RustcEncodable($item:item) {

core/src/prelude/v1.rs renamed to core/src/prelude/common.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
//! The first version of the core prelude.
1+
//! Items common to the prelude of all editions.
22
//!
33
//! See the [module-level documentation](super) for more.
44
5-
#![stable(feature = "core_prelude", since = "1.4.0")]
6-
75
// Re-exported core operators
86
#[stable(feature = "core_prelude", since = "1.4.0")]
97
#[doc(no_inline)]
@@ -68,11 +66,6 @@ pub use crate::{
6866
#[doc(no_inline)]
6967
pub use crate::concat_bytes;
7068

71-
// Do not `doc(inline)` these `doc(hidden)` items.
72-
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
73-
#[allow(deprecated)]
74-
pub use crate::macros::builtin::{RustcDecodable, RustcEncodable};
75-
7669
// Do not `doc(no_inline)` so that they become doc items on their own
7770
// (no public module for them to be re-exported from).
7871
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]

core/src/prelude/mod.rs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,26 @@
66
77
#![stable(feature = "core_prelude", since = "1.4.0")]
88

9-
pub mod v1;
9+
mod common;
10+
11+
/// The first version of the prelude of The Rust Standard Library.
12+
///
13+
/// See the [module-level documentation](self) for more.
14+
#[stable(feature = "rust1", since = "1.0.0")]
15+
pub mod v1 {
16+
#[stable(feature = "rust1", since = "1.0.0")]
17+
pub use super::common::*;
18+
19+
// Do not `doc(inline)` these `doc(hidden)` items.
20+
#[unstable(
21+
feature = "rustc_encodable_decodable",
22+
issue = "none",
23+
soft,
24+
reason = "derive macro for `rustc-serialize`; should not be used in new code"
25+
)]
26+
#[allow(deprecated)]
27+
pub use crate::macros::builtin::{RustcDecodable, RustcEncodable};
28+
}
1029

1130
/// The 2015 version of the core prelude.
1231
///
@@ -46,14 +65,21 @@ pub mod rust_2021 {
4665
pub use crate::convert::{TryFrom, TryInto};
4766
}
4867

49-
/// The 2024 edition of the core prelude.
68+
/// The 2024 version of the core prelude.
5069
///
5170
/// See the [module-level documentation](self) for more.
5271
#[unstable(feature = "prelude_2024", issue = "121042")]
5372
pub mod rust_2024 {
54-
#[unstable(feature = "prelude_2024", issue = "121042")]
73+
#[stable(feature = "rust1", since = "1.0.0")]
74+
pub use super::common::*;
75+
76+
#[stable(feature = "prelude_2021", since = "1.55.0")]
77+
#[doc(no_inline)]
78+
pub use crate::iter::FromIterator;
79+
80+
#[stable(feature = "prelude_2021", since = "1.55.0")]
5581
#[doc(no_inline)]
56-
pub use super::rust_2021::*;
82+
pub use crate::convert::{TryFrom, TryInto};
5783

5884
#[unstable(feature = "prelude_2024", issue = "121042")]
5985
#[doc(no_inline)]

std/src/prelude/v1.rs renamed to std/src/prelude/common.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
//! The first version of the prelude of The Rust Standard Library.
1+
//! Items common to the prelude of all editions.
22
//!
33
//! See the [module-level documentation](super) for more.
44
5-
#![stable(feature = "rust1", since = "1.0.0")]
6-
75
// Re-exported core operators
86
#[stable(feature = "rust1", since = "1.0.0")]
97
#[doc(no_inline)]
@@ -52,11 +50,6 @@ pub use core::prelude::v1::{
5250
#[doc(no_inline)]
5351
pub use core::prelude::v1::concat_bytes;
5452

55-
// Do not `doc(inline)` these `doc(hidden)` items.
56-
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
57-
#[allow(deprecated)]
58-
pub use core::prelude::v1::{RustcDecodable, RustcEncodable};
59-
6053
// Do not `doc(no_inline)` so that they become doc items on their own
6154
// (no public module for them to be re-exported from).
6255
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]

std/src/prelude/mod.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,26 @@
9393
9494
#![stable(feature = "rust1", since = "1.0.0")]
9595

96-
pub mod v1;
96+
mod common;
97+
98+
/// The first version of the prelude of The Rust Standard Library.
99+
///
100+
/// See the [module-level documentation](self) for more.
101+
#[stable(feature = "rust1", since = "1.0.0")]
102+
pub mod v1 {
103+
#[stable(feature = "rust1", since = "1.0.0")]
104+
pub use super::common::*;
105+
106+
// Do not `doc(inline)` these `doc(hidden)` items.
107+
#[unstable(
108+
feature = "rustc_encodable_decodable",
109+
issue = "none",
110+
soft,
111+
reason = "derive macro for `rustc-serialize`; should not be used in new code"
112+
)]
113+
#[allow(deprecated)]
114+
pub use core::prelude::v1::{RustcDecodable, RustcEncodable};
115+
}
97116

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

141159
#[unstable(feature = "prelude_2024", issue = "121042")]
142160
#[doc(no_inline)]

0 commit comments

Comments
 (0)