-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
rustdoc: skip blanket impls on recursive types #160173
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
Closed
+209
−41
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| //@ check-pass | ||
| // Regression test: blanket impls on recursive generic types caused | ||
| // `cargo doc` to take minutes instead of milliseconds. | ||
|
|
||
| use std::collections::{BTreeMap, BTreeSet}; | ||
| use std::sync::Arc; | ||
|
|
||
| pub trait Erasable: Sync {} | ||
| impl<T> Erasable for T where T: Sync {} | ||
|
|
||
| pub trait SessionParameters { | ||
| type Verifier; | ||
| } | ||
|
|
||
| pub struct Node<T>(pub Arc<T>); | ||
|
|
||
| pub struct ComputeScalar<SP: SessionParameters> { | ||
| pub args: BTreeMap<String, ComputeScalarArg<SP>>, | ||
| pub dependencies: Dependency<SP>, | ||
| } | ||
|
|
||
| pub struct Collect<SP: SessionParameters> { | ||
| pub values: CollectArg<SP>, | ||
| pub dependencies: Dependency<SP>, | ||
| } | ||
|
|
||
| pub struct ComputeMapping<SP: SessionParameters> { | ||
| pub args: BTreeMap<String, ComputeMappingArg<SP>>, | ||
| pub dependencies: Dependency<SP>, | ||
| } | ||
|
|
||
| pub struct SendBC<SP: SessionParameters> { | ||
| pub data: Node<SerializeAndSignBC<SP>>, | ||
| pub destinations: BTreeSet<SP::Verifier>, | ||
| pub dependencies: Dependency<SP>, | ||
| } | ||
|
|
||
| pub struct SerializeAndSignBC<SP: SessionParameters> { | ||
| pub data: Node<ComputeScalar<SP>>, | ||
| pub dependencies: Dependency<SP>, | ||
| } | ||
|
|
||
| pub struct SerializeAndSignDM<SP: SessionParameters> { | ||
| pub data: DirectMessageArg<SP>, | ||
| pub dependencies: Dependency<SP>, | ||
| } | ||
|
|
||
| pub struct DeserializeAndCheck<SP: SessionParameters> { | ||
| pub data: Node<Receive<SP>>, | ||
| pub dependencies: Dependency<SP>, | ||
| } | ||
|
|
||
| pub struct SendDM<SP: SessionParameters> { | ||
| pub data: Node<SerializeAndSignDM<SP>>, | ||
| pub dependencies: Dependency<SP>, | ||
| } | ||
|
|
||
| pub struct Receive<SP: SessionParameters> { | ||
| pub dependencies: Dependency<SP>, | ||
| } | ||
|
|
||
| pub struct MergeScalars<SP: SessionParameters> { | ||
| pub left: ComputeScalarArg<SP>, | ||
| pub right: ComputeScalarArg<SP>, | ||
| } | ||
|
|
||
| pub enum ComputeScalarArg<SP: SessionParameters> { | ||
| ComputeScalar(Node<ComputeScalar<SP>>), | ||
| MergeScalars(Node<MergeScalars<SP>>), | ||
| Collect(Node<Collect<SP>>), | ||
| } | ||
|
|
||
| pub enum ComputeMappingArg<SP: SessionParameters> { | ||
| ComputeScalar(Node<ComputeScalar<SP>>), | ||
| MergeScalars(Node<MergeScalars<SP>>), | ||
| Collect(Node<Collect<SP>>), | ||
| ComputeMapping(Node<ComputeMapping<SP>>), | ||
| SerializeAndSignBC(Node<SerializeAndSignBC<SP>>), | ||
| SerializeAndSignDM(Node<SerializeAndSignDM<SP>>), | ||
| DeserializeAndCheck(Node<DeserializeAndCheck<SP>>), | ||
| } | ||
|
|
||
| pub enum CollectArg<SP: SessionParameters> { | ||
| ComputeMapping(Node<ComputeMapping<SP>>), | ||
| SerializeAndSign(Node<SerializeAndSignDM<SP>>), | ||
| DeserializeAndCheck(Node<DeserializeAndCheck<SP>>), | ||
| Send(Node<SendDM<SP>>), | ||
| Receive(Node<Receive<SP>>), | ||
| } | ||
|
|
||
| pub enum DirectMessageArg<SP: SessionParameters> { | ||
| ComputeScalar(Node<ComputeScalar<SP>>), | ||
| ComputeMapping(Node<ComputeMapping<SP>>), | ||
| DeserializeAndCheck(Node<DeserializeAndCheck<SP>>), | ||
| } | ||
|
|
||
| pub enum Dependency<SP: SessionParameters> { | ||
| ComputeScalar(Node<ComputeScalar<SP>>), | ||
| Collect(Node<Collect<SP>>), | ||
| MergeScalars(Node<MergeScalars<SP>>), | ||
| SendBC(Node<SendBC<SP>>), | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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 is an extremely targeted fix that's also way too broad as it means that rustdoc stops showing blanket impls for all recursive data types which I don't consider acceptable.
The linked issue #160105 likely has the same root cause as #155759 and #114891.
The problem isn't with rustdoc's blanket impl synthesis, it's with the current trait solver. The next trait solver fixes this class of issues. Hence, I consider PR #125907 to be the principled fix (which is still blocked by some perf regressions caused by the switch).
What you're doing here is trying to patch faults of the trait solver from the outside just like PR #155765 which I'm also not a fan of.
View changes since the review
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.
@fmease thanks for looking into it. I see the issue and i will love to have my time to look deeper into it.. and will inform as soon as i get something.
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.
@fmease soo i dont see any way to fix this with the old trait solver. this must go under the new_trait_solver.. that you are already working on (#125907) here. soo you can close this PR..