Skip to content

Port #[target_feature] to new attribute parsing infrastructure #142876

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 1 commit into from
Jul 3, 2025

Conversation

JonathanBrouwer
Copy link
Contributor

Ports target_feature to the new attribute parsing infrastructure for #131229 (comment)

r? @jdonszelmann

@obi1kenobi
Copy link
Member

This should probably bump the rustdoc JSON FORMAT_VERSION too. This attribute is used by cargo-semver-checks today, and should probably also be in the rustdoc JSON test suite as well.

cc @aDotInTheVoid purely for awareness

@JonathanBrouwer
Copy link
Contributor Author

Ah, I missed it because it's not part of the tests for rustdoc-json. I'll make sure to give this attribute the nice formatting too, and to bump the FORMAT_VERSION

@obi1kenobi
Copy link
Member

Ah, I missed it because it's not part of the tests for rustdoc-json. I'll make sure to give this attribute the nice formatting too, and to bump the FORMAT_VERSION

You are my favorite person!

Just noting that this attribute has three valid forms:

  • it can be repeated on the same item, like #[target_feature(enable = "one")] #[target_feature(enable = "another")]
  • it can have multiple enable clauses, like #[target_feature(enable = "one", enable = "another")], and
  • it can have multiple features in the same enable clause, like #[target_feature(enable = "one,another")]

I believe any mix of these is also legal. For nice formatting, I don't have strong feelings how we normalize so long as we do normalize if at all possible. The last form is the most compact and IIRC how the attribute is explained in the docs, so all else equal that's what I'd pick if I were choosing. But feel free to do whatever is easiest.

And yes, entirely reasonable to miss it since we never tested it. We never tested it because it's only the new cargo-semver-checks releasing ~this week that uses it :)

@JonathanBrouwer
Copy link
Contributor Author

JonathanBrouwer commented Jun 22, 2025

I encountered these the hard way when writing the attribute :p I discover so much about Rust when doing these refactorings
Actually, since I do the pretty printing, does the FORMAT_VERSION even need to be bumped? Or does the normalizing count as a change?

@JonathanBrouwer JonathanBrouwer force-pushed the target_feature_parser branch from 8dd448b to 34dd949 Compare June 22, 2025 15:37
@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-rustdoc-json Area: Rustdoc JSON backend T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jun 22, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 22, 2025

These commits modify tests/rustdoc-json.
rustdoc-json is a public (but unstable) interface.

Please ensure that if you've changed the output:

  • It's intentional.
  • The FORMAT_VERSION in src/librustdoc-json-types is bumped if necessary.

cc @aDotInTheVoid, @obi1kenobi

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

Some changes occurred in compiler/rustc_codegen_ssa/src/codegen_attrs.rs

cc @jdonszelmann

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

Some changes occurred in compiler/rustc_attr_data_structures

cc @jdonszelmann

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

@JonathanBrouwer
Copy link
Contributor Author

This push should fix the pretty printing for rustdoc. Thanks for the feedback <3
I didn't end up bumping the FORMAT_VERSION but if I need to lmk

@obi1kenobi
Copy link
Member

I think normalizing to an already-valid form doesn't need to bump the format version, since any downstream consumers would have had to be able to handle it already.

@JonathanBrouwer
Copy link
Contributor Author

@rustbot ready
r? @jdonszelmann

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 22, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 22, 2025

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

@jdonszelmann
Copy link
Contributor

@rustbot author

@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 22, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 22, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@JonathanBrouwer JonathanBrouwer force-pushed the target_feature_parser branch from 34dd949 to c14ebc4 Compare June 22, 2025 19:37
@bors
Copy link
Collaborator

bors commented Jun 22, 2025

☔ The latest upstream changes (presumably #142878) made this pull request unmergeable. Please resolve the merge conflicts.

@JonathanBrouwer JonathanBrouwer force-pushed the target_feature_parser branch from c14ebc4 to 33e67cb Compare June 22, 2025 21:13
@JonathanBrouwer
Copy link
Contributor Author

Fixed the issues above & rebased on master
@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 22, 2025
@bors
Copy link
Collaborator

bors commented Jun 23, 2025

☔ The latest upstream changes (presumably #142901) made this pull request unmergeable. Please resolve the merge conflicts.

@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 Jul 1, 2025
@JonathanBrouwer JonathanBrouwer force-pushed the target_feature_parser branch from 15f0320 to fd6da8f Compare July 1, 2025 22:08
@rustbot
Copy link
Collaborator

rustbot commented Jul 1, 2025

Some changes occurred to constck

cc @fee1-dead

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

@JonathanBrouwer
Copy link
Contributor Author

^ I think I processed all your feedback @oli-obk
@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 Jul 1, 2025
@rust-log-analyzer

This comment has been minimized.

@JonathanBrouwer JonathanBrouwer force-pushed the target_feature_parser branch from fd6da8f to 7605dad Compare July 1, 2025 22:17
@bors
Copy link
Collaborator

bors commented Jul 3, 2025

☔ The latest upstream changes (presumably #143338) made this pull request unmergeable. Please resolve the merge conflicts.

@JonathanBrouwer JonathanBrouwer force-pushed the target_feature_parser branch from 7605dad to 3d5d72b Compare July 3, 2025 05:54
@JonathanBrouwer
Copy link
Contributor Author

^ Rebased

@oli-obk
Copy link
Contributor

oli-obk commented Jul 3, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 3, 2025

📌 Commit 3d5d72b has been approved by oli-obk

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 Jul 3, 2025
jdonszelmann added a commit to jdonszelmann/rust that referenced this pull request Jul 3, 2025
…ser, r=oli-obk

Port `#[target_feature]` to new attribute parsing infrastructure

Ports `target_feature` to the new attribute parsing infrastructure for rust-lang#131229 (comment)

r? `@jdonszelmann`
bors added a commit that referenced this pull request Jul 3, 2025
Rollup of 6 pull requests

Successful merges:

 - #134006 (setup typos check in CI)
 - #142876 (Port `#[target_feature]` to new attribute parsing infrastructure)
 - #143038 (avoid suggesting traits from private dependencies)
 - #143083 (Fix rustdoc not correctly showing attributes on re-exports)
 - #143283 (document optional jobs)
 - #143329 (minicore: use core's `diagnostic::on_unimplemented` messages)

Failed merges:

 - #143237 (Port `#[no_implicit_prelude]` to the new attribute parsing infrastructure)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5026d0c into rust-lang:master Jul 3, 2025
10 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jul 3, 2025
rust-timer added a commit that referenced this pull request Jul 3, 2025
Rollup merge of #142876 - JonathanBrouwer:target_feature_parser, r=oli-obk

Port `#[target_feature]` to new attribute parsing infrastructure

Ports `target_feature` to the new attribute parsing infrastructure for #131229 (comment)

r? ``@jdonszelmann``
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jul 4, 2025
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#134006 (setup typos check in CI)
 - rust-lang/rust#142876 (Port `#[target_feature]` to new attribute parsing infrastructure)
 - rust-lang/rust#143038 (avoid suggesting traits from private dependencies)
 - rust-lang/rust#143083 (Fix rustdoc not correctly showing attributes on re-exports)
 - rust-lang/rust#143283 (document optional jobs)
 - rust-lang/rust#143329 (minicore: use core's `diagnostic::on_unimplemented` messages)

Failed merges:

 - rust-lang/rust#143237 (Port `#[no_implicit_prelude]` to the new attribute parsing infrastructure)

r? `@ghost`
`@rustbot` modify labels: rollup
Kobzol pushed a commit to Kobzol/rustc-dev-guide that referenced this pull request Jul 4, 2025
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#134006 (setup typos check in CI)
 - rust-lang/rust#142876 (Port `#[target_feature]` to new attribute parsing infrastructure)
 - rust-lang/rust#143038 (avoid suggesting traits from private dependencies)
 - rust-lang/rust#143083 (Fix rustdoc not correctly showing attributes on re-exports)
 - rust-lang/rust#143283 (document optional jobs)
 - rust-lang/rust#143329 (minicore: use core's `diagnostic::on_unimplemented` messages)

Failed merges:

 - rust-lang/rust#143237 (Port `#[no_implicit_prelude]` to the new attribute parsing infrastructure)

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 (`#[…]`, `#![…]`) A-rustdoc-json Area: Rustdoc JSON backend 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants