Skip to content

refactor AttributeGate and rustc_attr! to emit notes during feature checking #141162

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
Jun 13, 2025

Conversation

mejrs
Copy link
Contributor

@mejrs mejrs commented May 17, 2025

First commit changes the following:

  • AttributeGate from an enum with (four) tuple fields to (five) named fields
  • adds a notes fields that is emitted as notes in the PostExpansionVisitor pass
  • removes the this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date note if the feature gate is rustc_attrs.
  • various phrasing changes and touchups
  • and finally, the reason why I went down this path to begin with: tell people they can use the diagnostic namespace when they hit the rustc_on_unimplemented feature gate 🙈

Second commit removes unused machinery for deprecated attributes

@rustbot
Copy link
Collaborator

rustbot commented May 17, 2025

r? @SparrowLii

rustbot has assigned @SparrowLii.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added 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 May 17, 2025
Comment on lines 839 to 836
BuiltinDeprecatedAttrLink { name, reason, link, suggestion },
BuiltinDeprecatedAttrLink { name: *name, message, link, suggestion },
Copy link
Contributor Author

@mejrs mejrs May 17, 2025

Choose a reason for hiding this comment

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

It looks like this code had some shadowing issues causing name to refer to the feature gate name, not the attribute. So I've changed it, but note that I think this function is dead code.

Copy link
Member

Choose a reason for hiding this comment

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

Hmmmmm. Why? If this is dead code then something is wrong. Could we add a test for deprecated attributes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmmmm. Why? If this is dead code then something is wrong. Could we add a test for deprecated attributes?

There are no deprecated attributes. Actually, #[macro_escape] is deprecated but it's not marked at such because it has its own diagnostic in rustc_resolve instead. This error has a branch on whether it's used as an inner or outer attribute, which the rustc_feature machinery does not support.

Rather than figure out some way to test this, I'd prefer to delete rustc_feature::Stability and this DeprecatedAttr lint pass instead, and have deprecations be done in check_attr.rs or in the new attribute parsing infra instead.

Copy link
Member

Choose a reason for hiding this comment

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

If you want to do it, feel free to. I'll mark this down as a followup on my to-do list (I will check it out later).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed in 16ae839

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@workingjubilee
Copy link
Member

cc @jdonszelmann

@jdonszelmann
Copy link
Contributor

I'll take a look

@mejrs
Copy link
Contributor Author

mejrs commented Jun 3, 2025

r? compiler

@rustbot rustbot assigned fee1-dead and unassigned SparrowLii Jun 3, 2025
Copy link
Member

@fee1-dead fee1-dead left a comment

Choose a reason for hiding this comment

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

Overall the direction seems fine.

Comment on lines 839 to 836
BuiltinDeprecatedAttrLink { name, reason, link, suggestion },
BuiltinDeprecatedAttrLink { name: *name, message, link, suggestion },
Copy link
Member

Choose a reason for hiding this comment

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

Hmmmmm. Why? If this is dead code then something is wrong. Could we add a test for deprecated attributes?

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 4, 2025
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot

This comment has been minimized.

@mejrs
Copy link
Contributor Author

mejrs commented Jun 4, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 4, 2025
Copy link
Member

@fee1-dead fee1-dead left a comment

Choose a reason for hiding this comment

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

r=me after the nit.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 6, 2025
@mejrs
Copy link
Contributor Author

mejrs commented Jun 6, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 6, 2025
@fee1-dead
Copy link
Member

Could you please squash this PR so it is two commits? One that is the refactor and one that is removing the stability.

@mejrs
Copy link
Contributor Author

mejrs commented Jun 9, 2025

Done

@fee1-dead
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 11, 2025

📌 Commit 81eb182 has been approved by fee1-dead

It is now in the queue for this repository.

@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 Jun 11, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 12, 2025
refactor  `AttributeGate` and `rustc_attr!` to emit notes during feature checking

First commit changes the following:

- `AttributeGate ` from an enum with (four) tuple fields to (five) named fields
- adds a `notes` fields that is emitted as notes in the `PostExpansionVisitor` pass
- removes the `this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date` note if the feature gate is `rustc_attrs`.
- various phrasing changes and touchups
- and finally, the reason why I went down this path to begin with: tell people they can use the diagnostic namespace when they hit the rustc_on_unimplemented feature gate 🙈

Second commit removes unused machinery for deprecated attributes
bors added a commit that referenced this pull request Jun 12, 2025
Rollup of 9 pull requests

Successful merges:

 - #138016 (Added `Clone` implementation for `ChunkBy`)
 - #140770 (add `extern "custom"` functions)
 - #141162 (refactor  `AttributeGate` and `rustc_attr!` to emit notes during feature checking)
 - #141474 (Add `ParseMode::Diagnostic` and fix multiline spans in diagnostic attribute lints)
 - #141947 (Specify that "option-like" enums must be `#[repr(Rust)]` to be ABI-compatible with their non-1ZST field.)
 - #142135 (docs: autogenerate compiler flag stubs based on -Zhelp)
 - #142252 (Improve clarity of `core::sync::atomic` docs about "Considerations" in regards to CAS operations)
 - #142337 (miri: add flag to suppress float non-determinism)
 - #142353 (compiler: Ease off the accelerator on `unsupported_calling_conventions`)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 12, 2025
refactor  `AttributeGate` and `rustc_attr!` to emit notes during feature checking

First commit changes the following:

- `AttributeGate ` from an enum with (four) tuple fields to (five) named fields
- adds a `notes` fields that is emitted as notes in the `PostExpansionVisitor` pass
- removes the `this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date` note if the feature gate is `rustc_attrs`.
- various phrasing changes and touchups
- and finally, the reason why I went down this path to begin with: tell people they can use the diagnostic namespace when they hit the rustc_on_unimplemented feature gate 🙈

Second commit removes unused machinery for deprecated attributes
bors added a commit that referenced this pull request Jun 12, 2025
Rollup of 8 pull requests

Successful merges:

 - #138016 (Added `Clone` implementation for `ChunkBy`)
 - #140770 (add `extern "custom"` functions)
 - #141162 (refactor  `AttributeGate` and `rustc_attr!` to emit notes during feature checking)
 - #141474 (Add `ParseMode::Diagnostic` and fix multiline spans in diagnostic attribute lints)
 - #141947 (Specify that "option-like" enums must be `#[repr(Rust)]` to be ABI-compatible with their non-1ZST field.)
 - #142252 (Improve clarity of `core::sync::atomic` docs about "Considerations" in regards to CAS operations)
 - #142337 (miri: add flag to suppress float non-determinism)
 - #142353 (compiler: Ease off the accelerator on `unsupported_calling_conventions`)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 12, 2025
refactor  `AttributeGate` and `rustc_attr!` to emit notes during feature checking

First commit changes the following:

- `AttributeGate ` from an enum with (four) tuple fields to (five) named fields
- adds a `notes` fields that is emitted as notes in the `PostExpansionVisitor` pass
- removes the `this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date` note if the feature gate is `rustc_attrs`.
- various phrasing changes and touchups
- and finally, the reason why I went down this path to begin with: tell people they can use the diagnostic namespace when they hit the rustc_on_unimplemented feature gate 🙈

Second commit removes unused machinery for deprecated attributes
bors added a commit that referenced this pull request Jun 12, 2025
Rollup of 7 pull requests

Successful merges:

 - #138016 (Added `Clone` implementation for `ChunkBy`)
 - #141162 (refactor  `AttributeGate` and `rustc_attr!` to emit notes during feature checking)
 - #141474 (Add `ParseMode::Diagnostic` and fix multiline spans in diagnostic attribute lints)
 - #141947 (Specify that "option-like" enums must be `#[repr(Rust)]` to be ABI-compatible with their non-1ZST field.)
 - #142252 (Improve clarity of `core::sync::atomic` docs about "Considerations" in regards to CAS operations)
 - #142337 (miri: add flag to suppress float non-determinism)
 - #142353 (compiler: Ease off the accelerator on `unsupported_calling_conventions`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jun 13, 2025
Rollup of 6 pull requests

Successful merges:

 - #138016 (Added `Clone` implementation for `ChunkBy`)
 - #141162 (refactor  `AttributeGate` and `rustc_attr!` to emit notes during feature checking)
 - #141474 (Add `ParseMode::Diagnostic` and fix multiline spans in diagnostic attribute lints)
 - #141947 (Specify that "option-like" enums must be `#[repr(Rust)]` to be ABI-compatible with their non-1ZST field.)
 - #142252 (Improve clarity of `core::sync::atomic` docs about "Considerations" in regards to CAS operations)
 - #142337 (miri: add flag to suppress float non-determinism)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 2591439 into rust-lang:master Jun 13, 2025
10 checks passed
@rustbot rustbot added this to the 1.89.0 milestone Jun 13, 2025
rust-timer added a commit that referenced this pull request Jun 13, 2025
Rollup merge of #141162 - mejrs:gated, r=fee1-dead

refactor  `AttributeGate` and `rustc_attr!` to emit notes during feature checking

First commit changes the following:

- `AttributeGate ` from an enum with (four) tuple fields to (five) named fields
- adds a `notes` fields that is emitted as notes in the `PostExpansionVisitor` pass
- removes the `this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date` note if the feature gate is `rustc_attrs`.
- various phrasing changes and touchups
- and finally, the reason why I went down this path to begin with: tell people they can use the diagnostic namespace when they hit the rustc_on_unimplemented feature gate 🙈

Second commit removes unused machinery for deprecated attributes
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jun 14, 2025
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#138016 (Added `Clone` implementation for `ChunkBy`)
 - rust-lang/rust#141162 (refactor  `AttributeGate` and `rustc_attr!` to emit notes during feature checking)
 - rust-lang/rust#141474 (Add `ParseMode::Diagnostic` and fix multiline spans in diagnostic attribute lints)
 - rust-lang/rust#141947 (Specify that "option-like" enums must be `#[repr(Rust)]` to be ABI-compatible with their non-1ZST field.)
 - rust-lang/rust#142252 (Improve clarity of `core::sync::atomic` docs about "Considerations" in regards to CAS operations)
 - rust-lang/rust#142337 (miri: add flag to suppress float non-determinism)

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
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.

8 participants