Skip to content
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

Don't print "private fields" on empty tuple structs #118192

Merged
merged 1 commit into from
Nov 23, 2023

Conversation

Kyuuhachi
Copy link
Contributor

Closes #118180.

While working on this I also noticed that empty struct variants are also rendered rather awkwardly. I'll make another issue for that, since I don't know what the correct rendering would be.

@rustbot
Copy link
Collaborator

rustbot commented Nov 23, 2023

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @jsha (or someone else) soon.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added 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 Nov 23, 2023
Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

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

As for the changes, this looks correct.

Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

This PR is almost good to go, I only have some suggestions for the added test: I'd turn the “absence checks” (@!has) into “presence checks” (@has) since they're more robust and future-proof. Furthermore, I wonder if the tests Hidden and Private are useful since we already have tests/rustdoc/private-fields-tuple-struct.rs for example.

@@ -0,0 +1,19 @@
// @has issue_118180_empty_tuple_struct/enum.Enum.html
pub enum Enum {
// @!has - '//*[@id="variant.Empty"]//h3' '/* private fields */'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// @!has - '//*[@id="variant.Empty"]//h3' '/* private fields */'
// @has - '//*[@id="variant.Empty"]//h3' 'Empty()'

}

// @has issue_118180_empty_tuple_struct/struct.Empty.html
// @!has - '//pre/code' '/* private fields */'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// @!has - '//pre/code' '/* private fields */'
// @has - '//pre/code' 'Empty()'

@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 Nov 23, 2023
@Kyuuhachi
Copy link
Contributor Author

Thanks for the feedback!

Presence rather than absence: sure. I think both are more future-proof in their own way, but if you think this way is better, fine with me.

As for the tests, I figured these would be edge cases that might plausibly be affected by a potential fix. But you are right — any such issues should be caught by the rest of the suite.

Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

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

Thanks! One last thing, could you maybe squash the commits? Since there aren't that many changes?

@fmease
Copy link
Member

fmease commented Nov 23, 2023

@!has is alright but imagine if we were to change /* private fields */ to /* hidden fields */ or something in this vein, then this test would become absolutely useless instead of continuing to test the right thing.

Test for presence rather than absence

Remove redundant tests

Issues in those parts will likely be caught by other parts of the test suite.
@Kyuuhachi
Copy link
Contributor Author

Sure. I think this is how I do that, right? (git rebase -i HEAD~3; git push --force-with-lease)

@fmease
Copy link
Member

fmease commented Nov 23, 2023

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Nov 23, 2023

📌 Commit a21d771 has been approved by fmease

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 23, 2023
@bors
Copy link
Contributor

bors commented Nov 23, 2023

⌛ Testing commit a21d771 with merge a4a5c97...

@bors
Copy link
Contributor

bors commented Nov 23, 2023

☀️ Test successful - checks-actions
Approved by: fmease
Pushing a4a5c97 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 23, 2023
@bors bors merged commit a4a5c97 into rust-lang:master Nov 23, 2023
12 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Nov 23, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a4a5c97): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 676.283s -> 675.669s (-0.09%)
Artifact size: 313.72 MiB -> 313.71 MiB (-0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

rustdoc: Tuple structs with no fields are marked as having private fields
7 participants