Skip to content

Fix ice for feature-gated cfg attributes applied to the crate #143984

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

Merged
merged 2 commits into from
Jul 17, 2025

Conversation

JonathanBrouwer
Copy link
Contributor

@JonathanBrouwer JonathanBrouwer commented Jul 15, 2025

This PR fixes two fixes:

  1. When a feature gated option of the cfg attribute is applied to the crate, an ICE would occur because features are not yet available at that stage. This is fixed by ignoring the feature gate at that point, the attribute will later be re-checked (this was already done) when the feature gate is available. Fixes ICE: features not available at this point in the compiler #143977
  2. Errors and lints on the cfg attribute applied to the crate would be produced twice, because of the re-checking. This is fixed by not producing any errors and lints during the first run.

The added regression test checks both problems.
r? @jdonszelmann

@rustbot
Copy link
Collaborator

rustbot commented Jul 15, 2025

jdonszelmann is currently at their maximum review capacity.
They may take a while to respond.

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 15, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 15, 2025

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

@rust-log-analyzer

This comment has been minimized.

@JonathanBrouwer
Copy link
Contributor Author

r? @Urgau if you wish, otherwise feel free to assign back to Jana

@rustbot rustbot assigned Urgau and unassigned jdonszelmann Jul 15, 2025
@Urgau
Copy link
Member

Urgau commented Jul 15, 2025

Thanks. r=me when PR CI is green

@bors delegate+

@bors
Copy link
Collaborator

bors commented Jul 15, 2025

✌️ @JonathanBrouwer, you can now approve this pull request!

If @Urgau told you to "r=me" after making some further change, please make that change, then do @bors r=@Urgau

@JonathanBrouwer
Copy link
Contributor Author

@bors r=@Urgau

@bors
Copy link
Collaborator

bors commented Jul 15, 2025

📌 Commit bfa45ac has been approved by Urgau

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jul 15, 2025

🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 15, 2025
@Urgau
Copy link
Member

Urgau commented Jul 16, 2025

@bors rollup

bors added a commit that referenced this pull request Jul 17, 2025
Rollup of 11 pull requests

Successful merges:

 - #143326 (Remove deprecated `Error::description` impl from `c_str::FromBytesWithNulError`)
 - #143431 (Use relative visibility when noting sealed trait to reduce false positive)
 - #143550 (resolve: Use interior mutability for extern module map)
 - #143631 (update to literal-escaper-0.0.5)
 - #143793 (Opaque type collection: Guard against endlessly recursing free alias types)
 - #143880 (tests: Test line debuginfo for linebreaked function parameters)
 - #143914 (Reword mismatched-lifetime-syntaxes text based on feedback)
 - #143926 (Remove deprecated fields in bootstrap)
 - #143955 (Make frame spans appear on a separate trace line)
 - #143975 (type_id_eq: check that the hash fully matches the type)
 - #143984 (Fix ice for feature-gated `cfg` attributes applied to the crate)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5286836 into rust-lang:master Jul 17, 2025
11 checks passed
rust-timer added a commit that referenced this pull request Jul 17, 2025
Rollup merge of #143984 - JonathanBrouwer:fix-feature-gate-ice, r=Urgau

Fix ice for feature-gated `cfg` attributes applied to the crate

This PR fixes two fixes:
1. When a feature gated option of the `cfg` attribute is applied to the crate, an ICE would occur because features are not yet available at that stage. This is fixed by ignoring the feature gate at that point, the attribute will later be re-checked (this was already done) when the feature gate is available. Fixes #143977
2. Errors and lints on the `cfg` attribute applied to the crate would be produced twice, because of the re-checking. This is fixed by not producing any errors and lints during the first run.

The added regression test checks both problems.
r? ``@jdonszelmann``
@rustbot rustbot added this to the 1.90.0 milestone Jul 17, 2025
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jul 18, 2025
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#143326 (Remove deprecated `Error::description` impl from `c_str::FromBytesWithNulError`)
 - rust-lang/rust#143431 (Use relative visibility when noting sealed trait to reduce false positive)
 - rust-lang/rust#143550 (resolve: Use interior mutability for extern module map)
 - rust-lang/rust#143631 (update to literal-escaper-0.0.5)
 - rust-lang/rust#143793 (Opaque type collection: Guard against endlessly recursing free alias types)
 - rust-lang/rust#143880 (tests: Test line debuginfo for linebreaked function parameters)
 - rust-lang/rust#143914 (Reword mismatched-lifetime-syntaxes text based on feedback)
 - rust-lang/rust#143926 (Remove deprecated fields in bootstrap)
 - rust-lang/rust#143955 (Make frame spans appear on a separate trace line)
 - rust-lang/rust#143975 (type_id_eq: check that the hash fully matches the type)
 - rust-lang/rust#143984 (Fix ice for feature-gated `cfg` attributes applied to the crate)

r? `@ghost`
`@rustbot` modify labels: rollup
Muscraft pushed a commit to Muscraft/rust that referenced this pull request Jul 21, 2025
…ce, r=Urgau

Fix ice for feature-gated `cfg` attributes applied to the crate

This PR fixes two fixes:
1. When a feature gated option of the `cfg` attribute is applied to the crate, an ICE would occur because features are not yet available at that stage. This is fixed by ignoring the feature gate at that point, the attribute will later be re-checked (this was already done) when the feature gate is available. Fixes rust-lang#143977
2. Errors and lints on the `cfg` attribute applied to the crate would be produced twice, because of the re-checking. This is fixed by not producing any errors and lints during the first run.

The added regression test checks both problems.
r? ``@jdonszelmann``
Muscraft pushed a commit to Muscraft/rust that referenced this pull request Jul 21, 2025
…iaskrgr

Rollup of 11 pull requests

Successful merges:

 - rust-lang#143326 (Remove deprecated `Error::description` impl from `c_str::FromBytesWithNulError`)
 - rust-lang#143431 (Use relative visibility when noting sealed trait to reduce false positive)
 - rust-lang#143550 (resolve: Use interior mutability for extern module map)
 - rust-lang#143631 (update to literal-escaper-0.0.5)
 - rust-lang#143793 (Opaque type collection: Guard against endlessly recursing free alias types)
 - rust-lang#143880 (tests: Test line debuginfo for linebreaked function parameters)
 - rust-lang#143914 (Reword mismatched-lifetime-syntaxes text based on feedback)
 - rust-lang#143926 (Remove deprecated fields in bootstrap)
 - rust-lang#143955 (Make frame spans appear on a separate trace line)
 - rust-lang#143975 (type_id_eq: check that the hash fully matches the type)
 - rust-lang#143984 (Fix ice for feature-gated `cfg` attributes applied to the crate)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: features not available at this point in the compiler
6 participants