Skip to content

rustdoc-json: Keep empty generic args if parenthesized #142932

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

Conversation

Enselic
Copy link
Member

@Enselic Enselic commented Jun 23, 2025

Because in the case of for example

pub fn my_fn3(f: impl FnMut()) {}

we want to keep () even if it is empty since that matches e.g. Rust syntax requirements.

This is an amendment to #142502, so:
r? @aDotInTheVoid
cc @nnethercote

cc cargo-public-api/cargo-public-api#798

Because in the case of for example

    pub fn my_fn3(f: impl FnMut()) {}

we want to keep `()` even if it is empty since that matches e.g. Rust
syntax requirements.
@rustbot rustbot added A-rustdoc-json Area: Rustdoc JSON backend S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jun 23, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 23, 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

@nnethercote
Copy link
Contributor

Good catch, it was unintentional to affect the parenthesized case. I think we'll need to bump FORMAT_VERSION and update the comment just above it, otherwise looks good.

@Enselic
Copy link
Member Author

Enselic commented Jun 23, 2025

Thanks for taking a look. I don't think we need to bump FORMAT_VERSION though since the format doesn't change? There is no change in how to interpret the JSON.

@nnethercote
Copy link
Contributor

I don't have a full handle on when to bump the version number. This change does alter the output in some cases, though as you say, how to interpret the output is unchanged. I'll defer to @aDotInTheVoid...

@aDotInTheVoid
Copy link
Member

Thanks for the fix.

Yeah, I don't think this needs a FORMAT_VERSION bump, as it won't break any deserialization, or parsing of strings contained within.

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jun 23, 2025

📌 Commit 7c0ef44 has been approved by aDotInTheVoid

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 23, 2025
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Jun 24, 2025
… r=aDotInTheVoid

rustdoc-json: Keep empty generic args if parenthesized

Because in the case of for example

    pub fn my_fn3(f: impl FnMut()) {}

we want to keep `()` even if it is empty since that matches e.g. Rust syntax requirements.

This is an amendment to rust-lang#142502, so:
r? `@aDotInTheVoid`
cc `@nnethercote`

cc cargo-public-api/cargo-public-api#798
bors added a commit that referenced this pull request Jun 24, 2025
Rollup of 8 pull requests

Successful merges:

 - #140622 (compiletest: Improve diagnostics for line annotation mismatches)
 - #142641 (Generate symbols.o for proc-macros too)
 - #142695 (Port `#[rustc_skip_during_method_dispatch]` to the new attribute system)
 - #142742 ([win][aarch64] Fix linking statics on Arm64EC, take 2)
 - #142894 (phantom_variance_markers: fix identifier usage in macro)
 - #142928 (Fix hang in --print=file-names in bootstrap)
 - #142930 (Account for beta revisions when normalizing versions)
 - #142932 (rustdoc-json: Keep empty generic args if parenthesized)

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

Successful merges:

 - #140005 (Set MSG_NOSIGNAL for UnixStream)
 - #140622 (compiletest: Improve diagnostics for line annotation mismatches)
 - #142354 (Fixes firefox copy paste issue)
 - #142695 (Port `#[rustc_skip_during_method_dispatch]` to the new attribute system)
 - #142779 (Add note about `str::split` handling of no matches.)
 - #142894 (phantom_variance_markers: fix identifier usage in macro)
 - #142928 (Fix hang in --print=file-names in bootstrap)
 - #142932 (rustdoc-json: Keep empty generic args if parenthesized)
 - #142933 (Simplify root goal API of solver a bit)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 010af6a into rust-lang:master Jun 24, 2025
10 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jun 24, 2025
rust-timer added a commit that referenced this pull request Jun 24, 2025
Rollup merge of #142932 - Enselic:keep-empty-generic-params, r=aDotInTheVoid

rustdoc-json: Keep empty generic args if parenthesized

Because in the case of for example

    pub fn my_fn3(f: impl FnMut()) {}

we want to keep `()` even if it is empty since that matches e.g. Rust syntax requirements.

This is an amendment to #142502, so:
r? ``@aDotInTheVoid``
cc ``@nnethercote``

cc cargo-public-api/cargo-public-api#798
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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-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.

5 participants