-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: An edition-compatible system for "removing" deprecated items from the standard library #3088
Conversation
(Errata: while researching this RFC I discovered two deprecated items that accidentally weren't deprecated at all, and additionally that the entire |
Would it make sense to have this redirection be a part of the (Also true of other lint attributes, like many of the |
I wish I had the time to write a longer comment, but I do not. Sorry in advance. Historically, I have not found sufficient motivation for actually hiding things. It doesn't have any of the traditional advantages of removal, because they're not removed, only hidden. It also creates work for people, for unclear (to me) benefit. Upon reading this RFC, it seems like the only clear benefit is "the documentation is smaller." I am not sure that that carries the weight of adding entire new mechanisms, and putting work on some of our users (and probably, our largest users...). |
My concern: People reading code sometimes search the docs for APIs used by that code in order to figure out what they do. (I hear that IDEs tend to have this built in, but personally I just do it by hand.) If we start removing items from the docs entirely, someone reading code from an old edition might try to look one up and be left baffled. |
@comex Maybe some kind of "collapse and/or fade" behaviour for APIs removed on the current edition so they don't draw undue attention from people working on the current edition but people working on older editions can still find them. Something like this but maybe with some kind of "removed" icon or annotation that's visible when collapsed without being as bulky and eye-catching as the current "Deprecated since" blocks: (I didn't think to try it, but maybe a strikethrough on the collapsed, faded elements which gets replaced with a "Removed in [edition]" block when expanded. That seems like an intuitive way to communicate what's going on.) |
Removing these from the generated documentation seems... not great. I'd like deprecations to become deny by default in newer editions, but if they're still in older editions I still might want to look them up in the docs. Making that harder seems like it has no advantages. |
Responding to comments:
Actually, this might already be supported, to a degree.
For users of the new edition these items would be effectively removed; the only stronger statement would be to
The goal is not smallness, rather it is that the documentation should not be permanently cluttered with things that users are encouraged not to use. To illustrate, as of Rust 1.52, of the 61 stable modules in the Rust stdlib, 12 of them will be marked as deprecated; a full fifth of the modules listed on the index page will be for modules that users are expected to ignore. Of course, due to the conservative policy proposed here, these specific modules would not actually be removed for several more years, but it would be nice to think that someday they would no longer clutter the index. This problem of increasing noise in the documentation is only going to become more acute as time passes; this RFC seeks to tackle it before it becomes too onerous.
This is addressed by the following:
An interesting idea, I'll add this to the alternatives section, and will pursue it further if there is continued resistance to the
The RFC's argument is not that there are no disadvantages, but rather that on balance it is a positive for consumers of the documentation. For example, see the search results page when searching for "max"; on my screen, of the 23 results that are immediately visible and above the fold, 14 of them are deprecated; if you were looking for a numeric constant, the 14 deprecated ones have pushed all but 3 of the suggested replacements off the bottom of the screen, below the fold. This is exacerbated by the fact that search results show no deprecation warning, and by the fact that deprecated items are sorting before non-deprecated ones; fixing both of these would involved annotating search results with additional markup and metadata, further swelling the enormous multi-megabyte JSON file that powers the search engine and which is starting to contribute to complaints of slowness of Rustdoc's search. Removing old deprecated items would free up size budget that could be spent treating newer deprecated items more intelligently, which would benefit every user of the docs, even those that aren't searching for anything related to a deprecated item. |
maybe deprecated things could be put in their own separate section at the end of the docs, minimized by default, such that you don't have to be distracted by them, but the docs are still there if you really need them. |
I don't think we should hide or remove the documentation for old deprecated APIs. The old edition still exists, code may still call those APIs, and the documentation should continue to be available. I do otherwise think this is a good idea. |
Closing based on the sentiment in the discussion at https://rust-lang.zulipchat.com/#narrow/stream/268952-edition-2021/topic/denying.20edition.202015.20deprecated.20APIs/near/237190120 . |
The discussion on zulip seemed to focus a lot on how this would be reflected in rustdoc in a way that's not confusing and is still useful for people on older editions. One option that I didn't see mentioned is to have a drop-down in the documentation to pick the edition. This dropdown would have "2015", "2018", "2021", etc. as options. If you select "2021", then items which were deprecated with the 2018 edition would be completely gone. Items which were deprecated with the 2021 edition would be present but marked as deprecated. If you select 2018 then all items accessible to the 2018 edition (including new ones added in 2021) are shown, and items deprecated with the 2018 edition are shown as deprecated. |
Yes, I think there are a lot of improvements that can be made to rustdoc in order to achieve much of what was proposed here. I intend to pursue those in the medium-term. |
The Rust standard library contains many items marked as "deprecated", implying that users should avoid using them in favor of alternatives. Despite their undesirability, these deprecated items can never be outright removed from the standard library, in keeping with Rust's stability guarantee. However, with the aid of the edition mechanism, the use of a deprecated item can be made into a compile-time error, thereby allowing such items to be "removed" from the standard library in a way that remains fully edition-compatible.
This RFC proposes the following:
#[doc(hidden)]
, thereby removing them from the generated documentation.A working implementation of the technical aspects of this proposal can be found here.
Rendered