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

rustdoc: make primitive synthetic impls for correct doc module #96301

Merged
merged 1 commit into from
Apr 22, 2022

Conversation

notriddle
Copy link
Contributor

@notriddle notriddle commented Apr 22, 2022

This improves the accuracy of libcore primitive docs, which was missing the blanket and auto impls for most primitive types. To test this, compare nightly libcore::str docs, which lack auto traits like Send, with libstd::str docs, which show them.

It also avoids getting synthetic impls for primitive types on crates that do not actually show them.

Before and After trace logs

Before

[notriddle@deep-thought test-dingus]$ RUSTDOC_LOG=rustdoc=trace rustdoc +nightly test.rs 2>&1 | grep -E 'get_blanket_impls\('
TRACE rustdoc::clean::blanket_impl get_blanket_impls(Whatever)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(isize)
TRACE rustdoc::clean::blanket_impl get_blanket_impls([T])
TRACE rustdoc::clean::blanket_impl get_blanket_impls([u8])
TRACE rustdoc::clean::blanket_impl get_blanket_impls([T])
TRACE rustdoc::clean::blanket_impl get_blanket_impls([u8])
TRACE rustdoc::clean::blanket_impl get_blanket_impls(char)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(u128)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(u16)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(i128)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(i16)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(str)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(str)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(f64)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(f64)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(u64)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(u8)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(i64)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(i8)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(*const T)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(*mut T)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(*const [T])
TRACE rustdoc::clean::blanket_impl get_blanket_impls(*mut [T])
TRACE rustdoc::clean::blanket_impl get_blanket_impls([T; N])
TRACE rustdoc::clean::blanket_impl get_blanket_impls(bool)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(f32)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(f32)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(u32)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(usize)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(i32)

After

[notriddle@deep-thought test-dingus]$ RUSTDOC_LOG=rustdoc=trace rustdoc +dev test.rs 2>&1 | grep -E 'get_blanket_impls\('
TRACE rustdoc::clean::blanket_impl get_blanket_impls(Whatever)

This improves the accuracy of libcore primitive docs, which was missing the
blanket and auto impls for most primitive types. To test this, compare nightly
[libcore::str] docs, which lack auto traits like Send, with [std::str] docs,
which show them.

[libcore::str]: https://doc.rust-lang.org/nightly/core/primitive.str.html
[libstd::str]: https://doc.rust-lang.org/nightly/std/primitive.str.html

It also avoids getting synthetic impls for primitive types on crates that
do not actually show them.

<details>

<summary>Before and After trace logs</summary>

Before:

	[notriddle@deep-thought test-dingus]$ RUSTDOC_LOG=rustdoc=trace rustdoc +nightly test.rs 2>&1 | grep -E 'get_blanket_impls\('
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(Whatever)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(isize)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls([T])
	TRACE rustdoc::clean::blanket_impl get_blanket_impls([u8])
	TRACE rustdoc::clean::blanket_impl get_blanket_impls([T])
	TRACE rustdoc::clean::blanket_impl get_blanket_impls([u8])
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(char)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(u128)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(u16)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(i128)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(i16)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(str)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(str)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(f64)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(f64)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(u64)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(u8)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(i64)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(i8)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(*const T)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(*mut T)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(*const [T])
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(*mut [T])
	TRACE rustdoc::clean::blanket_impl get_blanket_impls([T; N])
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(bool)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(f32)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(f32)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(u32)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(usize)
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(i32)

After:

	[notriddle@deep-thought test-dingus]$ RUSTDOC_LOG=rustdoc=trace rustdoc +dev test.rs 2>&1 | grep -E 'get_blanket_impls\('
	TRACE rustdoc::clean::blanket_impl get_blanket_impls(Whatever)

</details>
@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Apr 22, 2022
@rust-highfive
Copy link
Collaborator

r? @CraftSpider

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 22, 2022
@GuillaumeGomez
Copy link
Member

Tested locally and looks good to me. Let's run a perf check since I suppose it'll impact perf.

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 22, 2022
@bors
Copy link
Contributor

bors commented Apr 22, 2022

⌛ Trying commit 2e7b5ab with merge f78bea524380c39d97593ebadfdc905fdd5948e8...

@bors
Copy link
Contributor

bors commented Apr 22, 2022

☀️ Try build successful - checks-actions
Build commit: f78bea524380c39d97593ebadfdc905fdd5948e8 (f78bea524380c39d97593ebadfdc905fdd5948e8)

@rust-timer
Copy link
Collaborator

Queued f78bea524380c39d97593ebadfdc905fdd5948e8 with parent 8d68f2f, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f78bea524380c39d97593ebadfdc905fdd5948e8): comparison url.

Summary:

  • Primary benchmarks: 🎉 relevant improvements found
  • Secondary benchmarks: 🎉 relevant improvements found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 0 16 21 16
mean2 N/A N/A -1.2% -2.1% -1.2%
max N/A N/A -3.0% -3.3% -3.0%

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf -perf-regression

Footnotes

  1. number of relevant changes

  2. the arithmetic mean of the percent change

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 22, 2022
@GuillaumeGomez
Copy link
Member

Perfect. Let's go then!

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Apr 22, 2022

📌 Commit 2e7b5ab has been approved by GuillaumeGomez

@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 Apr 22, 2022
@bors
Copy link
Contributor

bors commented Apr 22, 2022

⌛ Testing commit 2e7b5ab with merge 5ffebc2...

@bors
Copy link
Contributor

bors commented Apr 22, 2022

☀️ Test successful - checks-actions
Approved by: GuillaumeGomez
Pushing 5ffebc2 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 22, 2022
@bors bors merged commit 5ffebc2 into rust-lang:master Apr 22, 2022
@rustbot rustbot added this to the 1.62.0 milestone Apr 22, 2022
@notriddle notriddle deleted the notriddle/synthetic-impl-prim branch April 22, 2022 19:36
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5ffebc2): comparison url.

Summary:

  • Primary benchmarks: 🎉 relevant improvements found
  • Secondary benchmarks: 🎉 relevant improvements found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 0 16 21 16
mean2 N/A N/A -1.2% -2.1% -1.2%
max N/A N/A -3.0% -3.3% -3.0%

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Footnotes

  1. number of relevant changes

  2. the arithmetic mean of the percent change

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.

7 participants