-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[rustdoc-json] Show whether ?Sized
parameters are actually Sized
#143559
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
base: master
Are you sure you want to change the base?
Conversation
|
This comment has been minimized.
This comment has been minimized.
I know this is WIP but if I may let me collect initial perf data (I've only skimmed the changes and haven't reviewed anything yet). [@]bors2 try [@]rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Show whether `?Sized` parameters are actually `Sized` A mostly-working, "some polish still required" attempt at fixing #143197 - Add a new `allow_unsized: bool` field to `GenericParamDefKind::Type`. - Expose that field as-is to rustdoc JSON, without tampering with `?Sized` clauses there. - Suppress `?Sized` from HTML where `Sized` is implied. I haven't figured out a good way to suppress `?Sized` from `impl Trait` in function parameters in HTML yet. The synthetic generics data doesn't seem to be "nearby" so more refactoring might be needed. I included a failing test case to remind me of this. r? fmease
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (55a9833): comparison URL. Overall result: ❌ regressions - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 1.6%, secondary 2.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.4%, secondary 2.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 463.852s -> 465.016s (0.25%) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I've not looked at the impl).
I agree that we should probably remove these misleading bounds in HTML.
But I wounder if we should do the same in JSON? Rather than having a separate bool
field?
|
||
// Generic functions | ||
//@ is "$.index[?(@.name=='func_custom')].inner.function.generics.params[0].kind.type.allow_unsized" false | ||
pub fn func_custom<T: ?Sized + CustomSized>() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should test that we don't remove the ?Sized
bound from the bounds list, even though it ends up not mattering.
It's a good question. I think there are two broadly-speaking reasonable choices, and one option we should avoid. We should avoid stripping Then the two broadly-acceptable options are both adding a bool, and differ over what the bool says:
I'm ambivalent between the two options, and could easily be talked into going for the second one if you have a strong preference that way. |
Taking a look at the benchmarks, I'm surprised that e.g. a simple "hello world" program takes 3% more instructions to document when there are no generics in it. This seems suspect — I wouldn't expect my code changes to get hit basically at all, let alone to the tune of a 3% slowdown. |
I'm strongly in favour if the first option. That way, consumers arn't required to look at that field if they don't need to.
EDIT: Stuff in here was incorrect, see fmeases comment below
pub fn foo<T: othercrate::Trait + ?Sized>(_t: T)
pub trait Trait {}
pub trait Trait: ?Sized {}
At the very least, the HTML change will want to go through a T-rustdoc-frontend fcp/poll. It's worth spinning of to a seperate PR, to unblock the JSON change. |
|
?Sized
parameters are actually Sized
?Sized
parameters are actually Sized
bba78b8
to
85e32ef
Compare
Updated to only include rustdoc JSON changes as suggested. If required, I plan to open a PR with the HTML changes separately after we have a final outcome on this PR. I've saved the old contents of the branch (including HTML changes and tests) under a different branch name. I believe this PR should now pass the rustdoc JSON test suite, and leave the HTML tests unchanged. I'm not sure what to do about the perf change, though it's possible removing the HTML changes has had some impact. It may be prudent to re-measure before we decide. @rustbot label -T-rustdoc-frontend |
rustdoc-json-types is a public (although nightly-only) API. If possible, consider changing cc @CraftSpider, @aDotInTheVoid, @Enselic, @obi1kenobi These commits modify Please ensure that if you've changed the output:
|
@bors2 try @rust-timer queue I’m happy this is the correct approach/behaviour/public api, but haven’t reviewed the implementation (yet). I’ll either do that in a week when I’m back from camping, or you could ask fmease (or someone else on T-Rustdoc) to do it beforehand. |
This comment has been minimized.
This comment has been minimized.
[rustdoc-json] Show whether `?Sized` parameters are actually `Sized`
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (c1707dd): comparison URL. Overall result: ❌ regressions - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 1.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.8%, secondary 2.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (secondary 0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 471.66s -> 469.982s (-0.36%) |
☔ The latest upstream changes (presumably #145970) made this pull request unmergeable. Please resolve the merge conflicts. |
An attempt at fixing #143197 for rustdoc JSON only, in order to streamline the review process. Any HTML changes will happen separately.
allow_unsized: bool
field toGenericParamDefKind::Type
.?Sized
clauses there.r? fmease