-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Destabilize RustcEncodable and RustcDecodable #92594
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @rust-highfive (or someone else) soon. Please see the contribution instructions for more information. |
r? highfive |
Is there a reason to feature-gate these vs. just removing them entirely? I believe these are still usable on stable -- the following compiles with rustc-serialize from crates.io in Cargo.toml, for example. So removal/de-stabilization is a breaking change, and I'm not sure if it's warranted. #[derive(RustcDecodable, RustcEncodable)]
struct Bar {
f: u32,
}
fn main() {
println!("{}", rustc_serialize::json::encode(&Bar { f: 3 }).unwrap());
} |
This comment has been minimized.
This comment has been minimized.
I featured gated them for now, but they could be removed entirely instead.
Indeed, which is why I suggested a crater run. |
By the way, why is |
There's a disturbingly high number of reverse dependencies on I think this definitely needs a Crater run. |
I guess because x.py wanted to? |
This comment has been minimized.
This comment has been minimized.
// #13544 | ||
// FIXME: This should be replaced with some other derive macro | ||
#![feature(rustc_encodable_decodable)] | ||
#[crate_type="lib"] // Why is this an outer attribute? |
There was a problem hiding this comment.
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:
#[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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was already a crater run 2.5 years ago - #62507 (comment). |
feature = "rustc_encodable_decodable", | ||
issue = "none", | ||
reason = "RustcDecodable cannot be used stably" | ||
)] |
There was a problem hiding this comment.
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.
library/core/src/macros/mod.rs
Outdated
#[unstable( | ||
feature = "rustc_encodable_decodable", | ||
issue = "none", | ||
reason = "RustcDecodable cannot be used stably" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reason = "RustcDecodable cannot be used stably" | |
reason = "unstable implementation detail of the `rustc` compiler, do not use" |
@@ -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}; |
There was a problem hiding this comment.
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.
I think this would be a good case the the recently-stabilized future-incompat-report future. Getting rustc to emit a report item for just these deprecations will require a few tweaks, though. |
If this is reported as the |
I was referring to #71249, which will show aessage to downstream crates relying on any of the direct users of these macros. |
I still would like to see an up-to-date crater run on making it fully-unstable, if possible. Not having an implementation detail of rustc be public and stable at all would be idea, but, if not that, then a deny-by-default fcw would be fair enough. Otherwise, there needs to probably be better documentation of the thing. |
Happy to queue up a Crater run on a hard error or deny by default lint -- is that the current state? I'd personally be fine with an r+ with something that lets dependencies still build -- deny by default lint, for example, seems reasonable. |
@craterbot retry |
🛠️ Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🎉 Experiment
|
FWIW, I stumbled across these recently and was confused by them. They look like they are defined in |
Ping from triage: When it's ready for review send a message containing |
Sorry about that. I got busy with other things. I've grabbed the logs, and want to go through them to see what crates failed, and whether the failures can be fixed. Until that time, it might be best just to proceed as-is, with the deny-by-default, rather than going straight for hard error. @rustbot ready |
// #13544 | ||
// FIXME: This should be replaced with some other derive macro | ||
#![feature(rustc_encodable_decodable)] | ||
#[crate_type="lib"] // Why is this an outer attribute? | ||
|
||
extern crate rustc_serialize; |
There was a problem hiding this comment.
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.
r=me with the PR description updated to reflect soft-deprecation and to avoid misleading commentary about inability to use these on stable. |
Of the published crates that this breaks, only 6 have a publication in the last year, and the median publication date is January 2017 (5 years ago). I tossed the list of broken crates from crater into a little script to grab repository links and last publication dates, for anyone who wants to peruse the list: broken-crates.gz |
@chorman0773 |
Oh sorry, been busy with other projects and haven't had a chance to work on
this. I'll look into making the requested fixes in a day or so.
…On Sun, 20 Mar 2022 at 01:28, John Simon ***@***.***> wrote:
@chorman0773 <https://github.com/chorman0773>
Ping from triage: Can you please post the status of this PR?
—
Reply to this email directly, view it on GitHub
<#92594 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABGLD2ZWXGJL735KDMKOY4LVA2ZOVANCNFSM5LK4SJ5Q>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Thanks for the ping but I think you meant @chorman0773 |
For posterity: this ended up being done in #116016. |
This adds the feature
rustc_encodable_decodable
and gates the previously stableRustcDecodable
andRustcEncodable
(though deprecated, hidden, and unusable) macros behind them.These macros have always been a mystery. They have no documentation (and are notably now hidden), cannot be used on stable (except to refer to them, which this PR changes) as their expansion references the
rustc_serialize
crate (which itself is only exposed asrustc_private
), and cannot reasonably be implemented outside of rustc (except as a compile error).They were deprecated in #83160, but as they cannot be expanded on stable, I see no reason why they cannot be made unstable (or alternatively, removed; I had no issues in rustc itself, from destabilizing the macros, and the only error was in libstd where the macro is reexported in the prelude), however, I would recommend a crater run to be sure (I highly doubt many crates have
use core::prelude::v1::RustcDecodable;
, though).See also: https://internals.rust-lang.org/t/what-is-rustc-decodable-encodable-and-why-is-it-stable/13744.