-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Target Version #1147
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
Closed
Closed
Target Version #1147
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
8bf55ca
new RFC: deprecation
llogiq cfc7d64
word wrapped, thanks to steveklabnik
llogiq 20666af
clarified how cargo gets rust version
llogiq fb16b8a
Merge branch 'master' of https://github.com/rust-lang/rfcs
llogiq 873f241
Added paragraph on how rustc should handle future target versions
llogiq 0754c8c
Fleshed out the Motivation section a bit
llogiq 984cc70
added future/legacy flags to alternatives
llogiq f5c7c56
More explanation about security issues
llogiq 5ffff4a
Clarified the paragraph about cargo/crates.io, also added Policy section
llogiq 1b0fe8c
clarification on insecurity and future-proofing
llogiq 704c985
added Cargo.toml-based target to Alternatives section
llogiq afb54c9
Almost complete rewrite.
llogiq 045c03e
Renamed --target to --target-version, reworded Cargo entry default
llogiq 2e44ed0
added open question about cargo and detailed design about feature fla…
llogiq 97b32e8
made 'rust' a package attribute instead of a pseudo-dependency
llogiq 62bda96
formatting improvements
llogiq b8f1490
Added previous proposal to alternatives, added bikeshedding to unreso…
llogiq d1e2725
Merge branch 'master' of https://github.com/rust-lang/rfcs
llogiq 955430b
#[insecure]-flagging removed from RFC, added some open questions (as …
llogiq 22108ae
Merge branch 'master' of https://github.com/rust-lang/rfcs
llogiq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
- Feature Name: A plan for deprecating APIs within Rust | ||
- Start Date: 2015-06-03 | ||
- RFC PR: | ||
- Rust Issue: | ||
|
||
# Summary | ||
|
||
There has been an ongoing [discussion on internals](https://internals.rust-lang.org/t/thoughts-on-aggressive-deprecation-in-libstd/2176/55) about how we are going to evolve the standard library. This RFC tries to condense the consensus | ||
|
||
# Motivation | ||
|
||
We want to guide the deprecation efforts to allow std to evolve freely to get the best possible API while ensuring minimum-breakage backwards compatibility for users and allow std authors to remove API items for a given version of Rust. Basically have our cake and eat it. Yum, cake. | ||
|
||
Of course we cannot really keep and remove a feature at the same time. To square this circle, we can follow the process outlined herein. | ||
|
||
# Detailed design | ||
|
||
We already declare deprecation in terms of Rust versions (like "1.0", "1.2"). The current attribute looks like `#[deprecated(since = "1.0.0", reason="foo")]`. This should be extended to add an optional `removed_at` key, to state that the item should be made inaccessible at that version. Note that while this allows for marking items as deprecated, there is absolutely no provision to actually *remove* items. In fact this proposal bans removing an API type outright, unless security concerns are deemed more important than the resulting breakage from removing it or the API item has some fault that means it cannot be used correctly at all (thus leaving the API in place would result in the same level of breakage than removing it). | ||
|
||
Currently every rustc version implements only its own version, having multiple versions is possible using something like multirust, though this does not work within a build. Also currently rustc versions do not guarantee interoperability. This RFC aims to change this situation. | ||
|
||
First, crates should state their target version using a `#![version = "1.0.0"]` attribute. Cargo should insert the current rust version by default on `cargo new` and *warn* if no version is defined on all other commands. It may optionally *note* that the specified target version is outdated on `cargo package`. [crates.io](https://crates.io) may deny packages that do not declare a version to give the target version requirement more weight to library authors. Cargo should also be able to hold back a new library version if its declared target version is newer than the rust version installed on the system. In those cases, cargo should emit a warning urging the user to upgrade their rust installation. | ||
|
||
`rustc` should use this target version definition to check for deprecated items. If no target version is defined, deprecation checking is deactivated (as we cannot assume a specific rust version), however a warning stating the same should be issued (as with cargo – we should probably make cargo not warn on build to get rid of duplicate warnings). Otherwise, use of API items whose `since` attribute is less or equal to the target version of the crate should trigger a warning, while API items whose `removed_at` attribute is less or equal to the target version should trigger an error. | ||
|
||
`rustdoc` should mark deprecated APIs as such (e.g. make them in a lighter gray font) and relegate removed APIs to a section below all others (and that may be hidden via a checkbox). We should not completely remove the documentation, as users of libraries that target old versions may still have a use for them, but neither should we let them clutter the docs. | ||
|
||
# Drawbacks | ||
|
||
By requiring full backwards-compatibility, we will never be able to actually remove stuff from the APIs, which will probably lead to some bloat. | ||
|
||
# Alternatives | ||
|
||
* Follow a more agressive strategy that actually removes stuff from the API. This would make it easier for the libstd creators at some cost for library and application writers, as they are required to keep up to date or face breakage | ||
* Hide deprecated items in the docs: This could be done either by putting them into a linked extra page or by adding a "show deprecated" checkbox that may be default be checked or not, depending on who you ask. This will however confuse people, who see the deprecated APIs in some code, but cannot find them in the docs anymore | ||
* Allow to distinguish "soft" and "hard" deprecation, so that an API can be marked as "soft" deprecated to dissuade new uses before hard deprecation is decided. Allowing people to specify deprecation in future version appears to have much of the same benefits without needing a new attribute key. | ||
* Decide deprecation on a per-case basis. This is what we do now. The proposal just adds a well-defined process to it | ||
* Never deprecate anything. Evolve the API by adding stuff only. Rust would be crushed by the weight of its own cruft before 2.0 even has a chance to land. Users will be uncertain which APIs to use | ||
|
||
# Unresolved questions | ||
|
||
Should we allow library writers to use the same features for deprecating their API items? |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
How should cargo do this? How does it know how to access different Rust versions?
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.
I have extended the paragraph to clarify. Basically either std defines a symbol with the current version, or
rustc -V
could be used after some post-processing.