-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustc_feature::Features: explain what that 'Option<Symbol>' is about #132098
Conversation
Question: is it worth it to introduce a struct with named fields instead of a 3-tuple? The comments are good -- but the callsite would still see the 3-tuple only. |
Possibly... I went for the faster version due to a lack of time, but feel free to take over and do the struct thing :)
|
/// Returns a list of triples with: | ||
/// - feature gate name | ||
/// - the span of the `#[feature]` attribute | ||
/// - (for already stable features) the version since which it is stable | ||
pub fn enabled_lang_features(&self) -> &Vec<(Symbol, Span, Option<Symbol>)> { |
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.
Discussion: not for this PR, but like
pub struct LangFeature {
name: Symbol,
attr_sp: Span,
stable_since: Option<Symbol>,
}
pub fn enabled_lang_features(&self) -> &Vec<LangFeature> { ... }
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.
The type should probably be called EnabledLangFeature
, but other than that -- yeah makes sense.
I'll see if it makes sense to package them into a struct in a follow-up. |
Thanks for the docs! r? jieyouxu |
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#129248 (Taking a raw ref (`&raw (const|mut)`) of a deref of pointer (`*ptr`) is always safe) - rust-lang#131906 (rustdoc: adjust spacing and typography in header) - rust-lang#132084 (Consider param-env candidates even if they have errors) - rust-lang#132096 (Replace an FTP link in comments with an equivalent HTTPS link) - rust-lang#132098 (rustc_feature::Features: explain what that 'Option<Symbol>' is about) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#132098 - RalfJung:features-since, r=jieyouxu rustc_feature::Features: explain what that 'Option<Symbol>' is about
Use `Enabled{Lang,Lib}Feature` instead of n-tuples Instead of passing around e.g. `(gate_name, attr_span, stable_since)` 3-tuples for enabled lang features or `(gate_name, attr_span)` 2-tuples for enabled lib features, use `Enabled{Lang,Lib}Feature` structs with named fields. Also did some minor code-golfing of involved iterator chains to hopefully make them easier to follow. Follow-up to rust-lang#132098 (comment) cc `@RalfJung.`
Rollup merge of rust-lang#132114 - jieyouxu:features-bundle, r=fee1-dead Use `Enabled{Lang,Lib}Feature` instead of n-tuples Instead of passing around e.g. `(gate_name, attr_span, stable_since)` 3-tuples for enabled lang features or `(gate_name, attr_span)` 2-tuples for enabled lib features, use `Enabled{Lang,Lib}Feature` structs with named fields. Also did some minor code-golfing of involved iterator chains to hopefully make them easier to follow. Follow-up to rust-lang#132098 (comment) cc `@RalfJung.`
No description provided.