-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Add stability inheritance #15029
Add stability inheritance #15029
Conversation
This commit makes several changes to the stability index infrastructure: * Stability levels are now inherited lexically, i.e., each item's stability level becomes the default for any nested items. * The computed stability level for an item is stored as part of the metadata. When using an item from an external crate, this data is looked up and cached. * The stability lint works from the computed stability level, rather than manual stability attribute annotations. However, the lint still checks only a limited set of item uses (e.g., it does not check every component of a path on import). This will be addressed in a later PR, as part of issue rust-lang#8962. * The stability lint only applies to items originating from external crates, since the stability index is intended as a promise to downstream crates. * The "experimental" lint is now _allow_ by default. This is because almost all existing crates have been marked "experimental", pending library stabilization. With inheritance in place, this would generate a massive explosion of warnings for every Rust program. The lint should be changed back to deny-by-default after library stabilization is complete. * The "deprecated" lint still warns by default. The net result: we can begin tracking stability index for the standard libraries as we stabilize, without impacting most clients. Closes rust-lang#13540.
You may be able to remove the stability attributes from the unused_attribute lint whitelist: https://github.com/rust-lang/rust/blob/master/src/librustc/middle/lint.rs#L1107 |
Would it be possible to having it on extern crate core; // warning: use of experimental crate
fn main() {
core::iter::Repeat::new(1); // no warning
} I imagine this kinda goes against the whole inheritance thing. Maybe the warning should only be on the "top-level"/first use of names with an explicit stability level, i.e. This would require warning on things like |
@huonw I also think that may be a useful way to treat experimental crates. I do think we can experiment with the ergonomics of how this is presented to the user later. Another approach that we were discussing was to have two modes: one that just reminds you a single time that you are using experimental/deprecated features, and another that displays them all individually for when you want to fix them. |
@aturon Have you noted any performance impact from this change? |
LGTM, but I'll wait to hear the response to the comments to r+. |
foo.trait_experimental_text(); | ||
foo.trait_unstable(); | ||
foo.trait_unstable_text(); | ||
foo.trait_unmarked(); |
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.
Could you move these cases to an external crate as well, and make sure they still invoke errors?
I think this was an exhaustiveness check to make sure stability is warned about in all possible cases.
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.
Maybe I'm misunderstanding, but I believe all of the cases are being checked in the cross_crate
module above.
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.
Aha, indeed!
@brson I did the following test on master and my branch: The user time was:
giving a 15s total overhead (i.e. 1.4%). The difference in real time was ~6s, or 0.7%. I'm not sure what the typical overhead for an additional pass over the AST is? If this seems too high to you, I can spend some time figuring out whether the overhead is coming from the extra pass or the lookups for the lint. |
@aturon you can get detailed pass break-down by passing |
Running stage2
These numbers are consistent across multiple runs. So I think my |
This commit makes several changes to the stability index infrastructure: * Stability levels are now inherited lexically, i.e., each item's stability level becomes the default for any nested items. * The computed stability level for an item is stored as part of the metadata. When using an item from an external crate, this data is looked up and cached. * The stability lint works from the computed stability level, rather than manual stability attribute annotations. However, the lint still checks only a limited set of item uses (e.g., it does not check every component of a path on import). This will be addressed in a later PR, as part of issue #8962. * The stability lint only applies to items originating from external crates, since the stability index is intended as a promise to downstream crates. * The "experimental" lint is now _allow_ by default. This is because almost all existing crates have been marked "experimental", pending library stabilization. With inheritance in place, this would generate a massive explosion of warnings for every Rust program. The lint should be changed back to deny-by-default after library stabilization is complete. * The "deprecated" lint still warns by default. The net result: we can begin tracking stability index for the standard libraries as we stabilize, without impacting most clients. Closes #13540.
Add more log in "terminator is none" assert cc rust-lang#15029
This commit makes several changes to the stability index infrastructure:
Stability levels are now inherited lexically, i.e., each item's
stability level becomes the default for any nested items.
The computed stability level for an item is stored as part of the
metadata. When using an item from an external crate, this data is
looked up and cached.
The stability lint works from the computed stability level, rather
than manual stability attribute annotations. However, the lint still
checks only a limited set of item uses (e.g., it does not check every
component of a path on import). This will be addressed in a later PR,
as part of issue Detect stability attributes on modules and crates #8962.
The stability lint only applies to items originating from external
crates, since the stability index is intended as a promise to
downstream crates.
The "experimental" lint is now allow by default. This is because
almost all existing crates have been marked "experimental", pending
library stabilization. With inheritance in place, this would generate
a massive explosion of warnings for every Rust program.
The lint should be changed back to deny-by-default after library
stabilization is complete.
The "deprecated" lint still warns by default.
The net result: we can begin tracking stability index for the standard
libraries as we stabilize, without impacting most clients.
Closes #13540.