-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Missing help when trying to enable stabilized library feature on stable #88802
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Hmm, this might be because it's a library feature and not a language feature? |
Mentoring instructions: include library features in this check:
|
@rustbot claim |
Hi! I started working on this but didn't know I had to claim it first. It's my first time contributing to open source. The remaining challenge is to combine two vectors with different data types. |
@vishadGoyal I appreciate your great work. You should work on this :) |
@rustbot claim |
Thanks a lot! I hope I didn't guilt you into doing this 😅 @chansuke |
Hi I'm having trouble with debugging my changes. I have made changes in https://github.com/rust-lang/rust/blob/497ee321af3b8496eaccd7af7b437f18bab81abf/compiler/rustc_ast_passes/src/feature_gate.rs Then I'm running I'm not seeing the effect of my changes when I do this. Also is there a way to debug this by attaching breakpoints? I don't think my approach of using the binary is the correct way to do this. |
@vishadGoyal this bit of code only runs on the beta and stable channels. Try setting
You can set |
I tried this but it says unknown field My config.toml
The output on running
|
@vishadGoyal it needs to be under one of the tables (I think maybe rust?). Look at config.toml.example, it will give an example. |
Thanks |
Feel free to make a PR adding it :) |
I'm facing a problem.
rust/compiler/rustc_feature/src/active.rs Line 47 in 547d937
rust/compiler/rustc_feature/src/active.rs Line 49 in 547d937
I searched the code and found that a list of all lib features can be queried from the rust/compiler/rustc_passes/src/stability.rs Line 964 in 547d937
and rust/compiler/rustc_passes/src/stability.rs Line 972 in 547d937
Is there a way to get the same data from the |
@vishadGoyal I think it would be reasonable to add it to rust/compiler/rustc_expand/src/config.rs Line 193 in c7dbe7a
|
The implementation there is to access the declared features in https://github.com/rust-lang/rust/tree/c7dbe7a830100c70d59994fd940bf75bb6e39b39/compiler/rustc_feature/src and if the feature name doesn't match with any of these, it is assumed to be a lib feature, the stable since data is still not there. However, I found the data in rust/library/core/src/intrinsics.rs Line 1864 in c7dbe7a
This is accessed via the HIR here,
and exposed via this query rust/compiler/rustc_middle/src/query/mod.rs Line 1411 in c7dbe7a
I have two questions:
|
@vishadGoyal yes, queries can only be run through a TyCtxt. No, I wouldn't expect so, there's the ast::Attributes but you need more than just a Session to access them. What's wrong with recording the |
The data is not already present where the declared_lib_features is currently being built. |
@vishadGoyal it should be in the attribute you're currently looking at - see how it's done in
The language features are hard-coded into the compiler, but that doesn't mean the library features aren't available, they just have to be determined at runtime. |
I logged the attribute being looked at
I couldn't find any stability attribute in it or it's meta. The output when I printed the meta of this attr was
|
@vishadGoyal you're looking at the Hmm, this may be tricky to do in parsing, since it's in another crate - I wonder if we could delay checking library features until later in the compiler, maybe to the pass where it checks if the feature is already stable? I remember @Mark-Simulacrum saying features were checked early to avoid stabilizing syntax by accident, but that shouldn't be an issue for library features: https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Why.20are.20feature.20gates.20checked.20during.20parsing.3F |
I'm new to this so can you explain why the treatment can be different for lang features and lib features? |
Library features can't affect the syntax passed to proc macros; language features can. |
So, what should be the ideal behavior in this scenario? |
@vishadGoyal you should still give a hard error, but it should be later in the compiler after the TyCtxt has been constructed, not during parsing. |
I've made the suggested changes. #89012 |
Suggest removing `#![feature]` for library features that have been stabilized Issue: rust-lang#88802 Delayed the check if #![feature] has been used to enable lib features in a non-nightly build to occur after TyCtxt has been constructed.
Fixed in #89012. |
Uh oh!
There was an error while loading. Please reload this page.
Given the following code:
The current output is:
Ideally the output should look like:
(or it could be downgraded from error to warning)
#83722 fixed this for
#![feature(min_const_generics)]
but not for#![feature(discriminant_value)]
, somehowThe text was updated successfully, but these errors were encountered: