-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Re-enable detection of unused library #![feature] directives #44232
Comments
Note that this also applies to the lint of "this |
Oh, so the "unused feature" lint is going to be disabled entirely? That could potentially unblock me over at #43017 (comment) as I currently can't figure out how to correctly populate the side table you're talking about. |
This commit primarily removes the `stability` field from `TyCtxt` as well as its internal mutable state, instead using a query to build the stability index as well as primarily using queries for other related lookups. Like previous commits the calculation of the stability index is wrapped in a `with_ignore` node to avoid regressing the current tests, and otherwise this commit also introduces rust-lang#44232 but somewhat intentionally so.
Maybe side tables are fundamentally incompatible with incremental and the set of used features (perhaps optimized as a bit map) should be part of the “result” of relevant compiler queries? |
Add errors for unknown, stable and duplicate feature attributes - Adds an error for unknown (lang and lib) features. - Extends the lint for unnecessary feature attributes for stable features to libs features (this already exists for lang features). - Adds an error for duplicate (lang and lib) features. ```rust #![feature(fake_feature)] //~ ERROR unknown feature `fake_feature` #![feature(i128_type)] //~ WARNING the feature `i128_type` has been stable since 1.26.0 #![feature(non_exhaustive)] #![feature(non_exhaustive)] //~ ERROR duplicate `non_exhaustive` feature attribute ``` Fixes #52053, fixes #53032 and address some of the problems noted in #44232 (though not unused features). There are a few outstanding problems, that I haven't narrowed down yet: - [x] Stability attributes on macros do not seem to be taken into account. - [x] Stability attributes behind `cfg` attributes are not taken into account. - [x] There are failing incremental tests.
How is this different from an unused item, say |
Visiting as part of compiler triage. I agree this would be nice, but it is certainly not P-high. It seems connected to the end-to-end query discussion. Based on Alex's comment, seems like there is some design work. In an effort to get somebody to maybe leave some thoughts, I'll cc @rust-lang/compiler, but not sure what else to do here. =) |
Hi, sorry to bother you with the old issue. I'm looking for a command or a tool to detect the unnecessary features and I found this issue. Would you please tell that if the issue is still in the plan? Thanks a lot. |
Currently the compiler will warn users about unused
#![feature]
directives if they're (a) a library feature and (b) not actually ever used. The compiler doesn't currently warn you about unused#![feature]
directives tied to language features.In the process of making the stability annotations more incremental-friendly (#44137) this check in the compiler has proven to be very difficult to make incremental. Namely what's happening here is:
check_stability
, which is used to verify that an API can actually be used.#![feature]
directives.This "put things in a table on the side" behavior isn't very incremental friently and isn't too easy to transition over to the query system. For now this specific warning seems like it probably isn't that important at Rust 1.20.0 (while it was probably very important at Rust 1.0.0). I'm going to comment this out for now so we're not going to get lints/warnings about unused library features.
This is a FIXME to track re-enabling this warning!
The text was updated successfully, but these errors were encountered: