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

Strip impl if not re-exported and is doc(hidden) #113574

Merged
merged 5 commits into from
Jul 18, 2023

Conversation

GuillaumeGomez
Copy link
Member

Part of #112852.

r? @aDotInTheVoid

@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 Jul 11, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 12, 2023
…name, r=notriddle

Allow to have `-` in rustdoc-json test file name

I extracted this commit from rust-lang#113574.

When I added the test, it kept saying that the JSON file couldn't be found. After investigating for a while, I discovered that we were expecting files to always use `_`, which is quite bad. So I added support for `-` in file names.

r? `@notriddle`
@aDotInTheVoid
Copy link
Member

What else is needed to close #112852? Just tests?

@GuillaumeGomez
Copy link
Member Author

Yes, more tests.

@GuillaumeGomez
Copy link
Member Author

Applied comments.

@aDotInTheVoid
Copy link
Member

Applied comments.

IDK why GitHub highlighted it differently, but I also suggested adding // @!has "$.index[*][?(@.inner.impl)]"

Yes, more tests.

Could they be added now? This code contains logic (that AFAIKT is right) for handling reexports, but if it's wrong, I'd like to know now, and not when doing a follow-up PR to add tests.

@GuillaumeGomez
Copy link
Member Author

Sure I don't mind. I just have no idea what tests to add. If you have ideas, please don't hesitate. :)

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 13, 2023
…name, r=notriddle

Allow to have `-` in rustdoc-json test file name

I extracted this commit from rust-lang#113574.

When I added the test, it kept saying that the JSON file couldn't be found. After investigating for a while, I discovered that we were expecting files to always use `_`, which is quite bad. So I added support for `-` in file names.

r? ``@notriddle``
@aDotInTheVoid
Copy link
Member

Sure I don't mind. I just have no idea what tests to add. If you have ideas, please don't hesitate. :)

See here

When this is fixed, we should add tests for these 2 cases, them with a pub use of the struct, them with --document-hidden-items, and them with --document-hidden-items and a pub use.

@GuillaumeGomez
Copy link
Member Author

I added two more tests. To fix the -3 one, I had to actually fix the --document-hidden-items option in rustdoc which was handled very poorly.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member Author

Fixed the CI errors.

@GuillaumeGomez
Copy link
Member Author

Considering it got completely away from JSON (because of --document-hidden-items), I'll set @notriddle as reviewer.

r? @notriddle

@rustbot rustbot assigned notriddle and unassigned aDotInTheVoid Jul 17, 2023
@notriddle
Copy link
Contributor

The #[doc(hidden)] changes seem reasonable to me.

#![no_core]

// @!has "$.index[*][?(@.name == 'HiddenPubStruct')]"
// @!has "$.index[*][?(@.inner.impl)]"
Copy link
Contributor

Choose a reason for hiding this comment

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

!has tests are fragile when the schema changes. The ideal way to write it would be a version that has two structs, and asserts that exactly one shows up.

// @count "$.index[*][?(@.inner.impl)]" 1
// @!has "$.index[*][?(@.name == 'HiddenPubStruct')]"
// @has "$.index[*][?(@.name == 'NotHiddenPubStruct')]"
// @has "$.index[*][?(@.name=='PubTrait')]"
pub trait PubTrait {}

#[doc(hidden)]
pub mod hidden {
    pub struct HiddenPubStruct;

    impl crate::PubTrait for HiddenPubStruct {}
}

pub mod not_hidden {
    pub struct NotHiddenPubStruct;

    impl crate::PubTrait for HiddenPubStruct {}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

That's still not ideal (I really don't like @!has) but in JSON what you suggested is already much better. Going to update.

@GuillaumeGomez
Copy link
Member Author

Updated!

@aDotInTheVoid
Copy link
Member

@bors r=aDotInTheVoid,notriddle

@bors
Copy link
Contributor

bors commented Jul 17, 2023

📌 Commit c132cdb has been approved by aDotInTheVoid,notriddle

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 17, 2023
@bors
Copy link
Contributor

bors commented Jul 18, 2023

⌛ Testing commit c132cdb with merge ec362f0...

@bors
Copy link
Contributor

bors commented Jul 18, 2023

☀️ Test successful - checks-actions
Approved by: aDotInTheVoid,notriddle
Pushing ec362f0 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 18, 2023
@bors bors merged commit ec362f0 into rust-lang:master Jul 18, 2023
@rustbot rustbot added this to the 1.73.0 milestone Jul 18, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ec362f0): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.5% [0.5%, 0.5%] 1
Regressions ❌
(secondary)
0.6% [0.5%, 0.8%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.5% [0.5%, 0.5%] 1

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.5% [1.1%, 5.3%] 7
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.5% [1.1%, 5.3%] 7

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: 659.727s -> 657.921s (-0.27%)

@GuillaumeGomez GuillaumeGomez deleted the rustdoc-json-strip-hidden-impl branch July 18, 2023 08:37
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 20, 2023
…ms-test, r=notriddle

Add tests for `--document-hidden-items` option

Since `--document-hidden-items` was greatly fixed/improved in rust-lang#113574, thought it might be worth adding some more tests for it to prevent new regressions.

As for the first commit, it allows to go from:

```
Traceback (most recent call last):
  File "/home/imperio/rust/rust/src/etc/htmldocck.py", line 706, in <module>
    check(sys.argv[1], get_commands(rust_test_path))
  File "/home/imperio/rust/rust/src/etc/htmldocck.py", line 689, in check
    for c in commands:
  File "/home/imperio/rust/rust/src/etc/htmldocck.py", line 274, in get_commands
    args = shlex.split(args)
  File "/usr/lib/python3.10/shlex.py", line 315, in split
    return list(lex)
  File "/usr/lib/python3.10/shlex.py", line 300, in __next__
    token = self.get_token()
  File "/usr/lib/python3.10/shlex.py", line 109, in get_token
    raw = self.read_token()
  File "/usr/lib/python3.10/shlex.py", line 191, in read_token
    raise ValueError("No closing quotation")
ValueError: No closing quotation
```

to:

```
Traceback (most recent call last):
  File "/home/imperio/rust/rust/src/etc/htmldocck.py", line 708, in <module>
    check(sys.argv[1], get_commands(rust_test_path))
  File "/home/imperio/rust/rust/src/etc/htmldocck.py", line 691, in check
    for c in commands:
  File "/home/imperio/rust/rust/src/etc/htmldocck.py", line 278, in get_commands
    raise Exception("line {}: {}".format(lineno + 1, exc)) from None
Exception: line 57: No closing quotation
```

Having the line where the error occurred is quite useful.

r? `@notriddle`
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 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.

7 participants