Skip to content

Document feature gate checking#2750

Merged
tshepang merged 4 commits intorust-lang:mainfrom
reddevilmidzy:fgc
Feb 3, 2026
Merged

Document feature gate checking#2750
tshepang merged 4 commits intorust-lang:mainfrom
reddevilmidzy:fgc

Conversation

@reddevilmidzy
Copy link
Member

@reddevilmidzy reddevilmidzy commented Jan 30, 2026

close: #1158

I tried to document it by looking at the code, and I welcome any feedback 😀

r? rustc-dev-guide

@rustbot rustbot added the S-waiting-on-review Status: this PR is waiting for a reviewer to verify its content label Jan 30, 2026

### Checking `GatedSpans`

`check_crate` iterates over `sess.psess.gated_spans`:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this make it seem like it's not a continuation of line 65... maybe line 65 could have a link to this, or that the content of this section should be added under line 65

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's right, I changed the location of the section and added a link just in case

Comment on lines 102 to 103
- [`rustc_attr_parsing/src/attributes/cfg.rs`] defines
`find_gated_cfg`/`gate_cfg` to reject gated `cfg`s.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see find_gated_cfg is defined elsewhere

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I changed it to rustc_feature::find_gated_cfg. Thank you.

Comment on lines 32 to 33
- **Accepted** features are recorded but do not require nightly. On
stable/beta they trigger the "already stabilized" diagnostic.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do I follow the logic to verify that the diagnostic only happens on stable/beta

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added explanation!

@tshepang
Copy link
Member

tshepang commented Feb 2, 2026

I would add a date-check and also change the filename, perhaps -check instead of -ck

Copy link
Member Author

@reddevilmidzy reddevilmidzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for the review

Comment on lines 102 to 103
- [`rustc_attr_parsing/src/attributes/cfg.rs`] defines
`find_gated_cfg`/`gate_cfg` to reject gated `cfg`s.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I changed it to rustc_feature::find_gated_cfg. Thank you.


### Checking `GatedSpans`

`check_crate` iterates over `sess.psess.gated_spans`:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's right, I changed the location of the section and added a link just in case

Comment on lines 32 to 33
- **Accepted** features are recorded but do not require nightly. On
stable/beta they trigger the "already stabilized" diagnostic.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added explanation!

@tshepang
Copy link
Member

tshepang commented Feb 3, 2026

thanks... learned a lot reviewing this

just needs a git conflict fix

@rustbot
Copy link
Collaborator

rustbot commented Feb 3, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@reddevilmidzy
Copy link
Member Author

thanks... learned a lot reviewing this

just needs a git conflict fix

Resolved the conflict by rebasing,

I learned a lot while documenting it too. 😃

@tshepang tshepang merged commit 3079be0 into rust-lang:main Feb 3, 2026
1 check passed
@rustbot rustbot removed the S-waiting-on-review Status: this PR is waiting for a reviewer to verify its content label Feb 3, 2026
@tshepang
Copy link
Member

tshepang commented Feb 3, 2026

There is another chapter on feature gates, as well as other mentions of feature gates in the book. I wonder how we can harmonize them, because they, at the moment, mostly don't know about each other.

@reddevilmidzy
Copy link
Member Author

There is another chapter on feature gates, as well as other mentions of feature gates in the book. I wonder how we can harmonize them, because they, at the moment, mostly don't know about each other.

I was thinking about that early in the process, but I seem to have forgotten about it 😅

These two topics are related to feature gates, but they cover different topics. So, I'll keep the current document location and add sentences and links to connect them!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document feature gate checking

3 participants