Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0dcc130

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 37f9798 + fbf21c5 commit 0dcc130

File tree

8 files changed

+156
-40
lines changed

8 files changed

+156
-40
lines changed

‎library/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) {

‎library/core/src/prelude/v1.rs‎ renamed to ‎library/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")]

‎library/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)]

‎library/std/src/prelude/v1.rs‎ renamed to ‎library/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")]

‎library/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)]
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
#[crate_type="lib"]
2-
31
// #13544
42

5-
extern crate rustc_serialize;
6-
7-
#[derive(RustcEncodable)] pub struct A;
8-
#[derive(RustcEncodable)] pub struct B(isize);
9-
#[derive(RustcEncodable)] pub struct C { x: isize }
10-
#[derive(RustcEncodable)] pub enum D {}
11-
#[derive(RustcEncodable)] pub enum E { y }
12-
#[derive(RustcEncodable)] pub enum F { z(isize) }
3+
#[derive(Debug)] pub struct A;
4+
#[derive(Debug)] pub struct B(isize);
5+
#[derive(Debug)] pub struct C { x: isize }
6+
#[derive(Debug)] pub enum D {}
7+
#[derive(Debug)] pub enum E { y }
8+
#[derive(Debug)] pub enum F { z(isize) }
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#![crate_type = "lib"]
2+
3+
// This isn't intended to compile, so it's easiest to just ignore this error.
4+
extern crate rustc_serialize; //~ERROR can't find crate for `rustc_serialize`
5+
6+
#[derive(
7+
RustcEncodable,
8+
//~^ ERROR use of unstable library feature 'rustc_encodable_decodable'
9+
//~^^ WARNING this was previously accepted by the compiler
10+
//~^^^ WARNING use of deprecated macro `RustcEncodable`
11+
RustcDecodable,
12+
//~^ ERROR use of unstable library feature 'rustc_encodable_decodable'
13+
//~^^ WARNING this was previously accepted by the compiler
14+
//~^^^ WARNING use of deprecated macro `RustcDecodable`
15+
)]
16+
struct S;
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
error[E0463]: can't find crate for `rustc_serialize`
2+
--> $DIR/feature-gate-rustc_encodable_decodable.rs:4:1
3+
|
4+
LL | extern crate rustc_serialize;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
6+
|
7+
= help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`
8+
9+
error: use of unstable library feature 'rustc_encodable_decodable': derive macro for `rustc-serialize`; should not be used in new code
10+
--> $DIR/feature-gate-rustc_encodable_decodable.rs:7:5
11+
|
12+
LL | RustcEncodable,
13+
| ^^^^^^^^^^^^^^
14+
|
15+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
16+
= note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
17+
= note: `#[deny(soft_unstable)]` on by default
18+
19+
warning: use of deprecated macro `RustcEncodable`: rustc-serialize is deprecated and no longer supported
20+
--> $DIR/feature-gate-rustc_encodable_decodable.rs:7:5
21+
|
22+
LL | RustcEncodable,
23+
| ^^^^^^^^^^^^^^
24+
|
25+
= note: `#[warn(deprecated)]` on by default
26+
27+
error: use of unstable library feature 'rustc_encodable_decodable': derive macro for `rustc-serialize`; should not be used in new code
28+
--> $DIR/feature-gate-rustc_encodable_decodable.rs:11:5
29+
|
30+
LL | RustcDecodable,
31+
| ^^^^^^^^^^^^^^
32+
|
33+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
34+
= note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
35+
36+
warning: use of deprecated macro `RustcDecodable`: rustc-serialize is deprecated and no longer supported
37+
--> $DIR/feature-gate-rustc_encodable_decodable.rs:11:5
38+
|
39+
LL | RustcDecodable,
40+
| ^^^^^^^^^^^^^^
41+
42+
error: aborting due to 3 previous errors; 2 warnings emitted
43+
44+
For more information about this error, try `rustc --explain E0463`.
45+
Future incompatibility report: Future breakage diagnostic:
46+
error: use of unstable library feature 'rustc_encodable_decodable': derive macro for `rustc-serialize`; should not be used in new code
47+
--> $DIR/feature-gate-rustc_encodable_decodable.rs:7:5
48+
|
49+
LL | RustcEncodable,
50+
| ^^^^^^^^^^^^^^
51+
|
52+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
53+
= note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
54+
= note: `#[deny(soft_unstable)]` on by default
55+
56+
Future breakage diagnostic:
57+
error: use of unstable library feature 'rustc_encodable_decodable': derive macro for `rustc-serialize`; should not be used in new code
58+
--> $DIR/feature-gate-rustc_encodable_decodable.rs:11:5
59+
|
60+
LL | RustcDecodable,
61+
| ^^^^^^^^^^^^^^
62+
|
63+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
64+
= note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
65+
= note: `#[deny(soft_unstable)]` on by default
66+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /