rustdoc: re-sugar more cross-crate trait bounds#102439
Merged
bors merged 1 commit intorust-lang:masterfrom Oct 3, 2022
Merged
Conversation
fmease
commented
Sep 29, 2022
GuillaumeGomez
approved these changes
Sep 30, 2022
Member
|
Looks really good! Please ping me once you have some answers about the empty |
f146915 to
a540234
Compare
Member
Author
|
I've changed my mind. I think it's better if we merge this PR as-is leaving the On the other hand, the HRTB fix is slightly more involved (although not that much more). I am going to submit the first follow-up PR within the next few hours or so. |
GuillaumeGomez
approved these changes
Oct 3, 2022
Member
|
Then let's go! @bors r+ rollup |
Collaborator
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Oct 3, 2022
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#102439 (rustdoc: re-sugar more cross-crate trait bounds) - rust-lang#102569 (Improve `FromStr` example) - rust-lang#102597 (Avoid ICE in printing RPITIT type) - rust-lang#102607 (Improve documentation of `slice::{from_ptr_range, from_ptr_range_mut}`) - rust-lang#102613 (Fix ICE rust-lang#101739) - rust-lang#102615 (Cleanup some error code explanations) - rust-lang#102617 (`HirId` for `deferred_transmute_checks`) - rust-lang#102620 (Migrate `.stab` elements style to CSS variables) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Oct 6, 2022
…te-hrtbs-properly, r=GuillaumeGomez rustdoc: render more cross-crate HRTBs properly Follow-up to rust-lang#102439. Render the `for<>` parameter lists of cross-crate higher-rank trait bounds (in where-clauses and in `impl Trait`). I've added a new field `bound_params` to `clean::WherePredicate::EqPredicate` (mirroring its sibling variant `BoundPredicate`). However, I had to box the existing fields since `EqPredicate` used to be the largest variant (128 bytes on 64-bit systems) and it would only have gotten bigger). Not sure if you like that approach. As an alternative, I could pass the uncleaned `ty::Predicate` alongside the cleaned `WherePredicate` to the various re-sugaring methods (similar to what `clean::AutoTraitFinder::param_env_to_generics` does). I haven't yet added the HTML & JSON rendering code for the newly added `bound_params` field since I am waiting for your opinion. Those two rendering code paths should actually be unreachable in practice given we re-sugar all(?) equality predicates to associated type bindings (and arbitrary equality predicates are not part of the Rust surface language at the time of this writing). If you agree with storing `bound_params` in `EqPredicate`, I think I can use it to greatly simplify the `clean::auto_trait` module (by also using `simplify::merge_bounds`). Maybe I can do that in any case though. `@rustbot` label T-rustdoc A-cross-crate-reexports r? `@GuillaumeGomez`
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Oct 20, 2022
…oss-crate-gat-params, r=GuillaumeGomez rustdoc: render bounds of cross-crate GAT params Follow-up to rust-lang#102439. Render the trait bounds of type parameters of cross-crate (generic) associated types. `@rustbot` label T-rustdoc A-cross-crate-reexports r? `@GuillaumeGomez`
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Oct 20, 2022
…oss-crate-gat-params, r=GuillaumeGomez rustdoc: render bounds of cross-crate GAT params Follow-up to rust-lang#102439. Render the trait bounds of type parameters of cross-crate (generic) associated types. ``@rustbot`` label T-rustdoc A-cross-crate-reexports r? ``@GuillaumeGomez``
Dylan-DPC
added a commit
to Dylan-DPC/rust
that referenced
this pull request
Oct 22, 2022
…oss-crate-gat-params, r=GuillaumeGomez rustdoc: render bounds of cross-crate GAT params Follow-up to rust-lang#102439. Render the trait bounds of type parameters of cross-crate (generic) associated types. ```@rustbot``` label T-rustdoc A-cross-crate-reexports r? ```@GuillaumeGomez```
Dylan-DPC
added a commit
to Dylan-DPC/rust
that referenced
this pull request
Oct 22, 2022
…oss-crate-gat-params, r=GuillaumeGomez rustdoc: render bounds of cross-crate GAT params Follow-up to rust-lang#102439. Render the trait bounds of type parameters of cross-crate (generic) associated types. ````@rustbot```` label T-rustdoc A-cross-crate-reexports r? ````@GuillaumeGomez````
Dylan-DPC
added a commit
to Dylan-DPC/rust
that referenced
this pull request
Oct 22, 2022
…oss-crate-gat-params, r=GuillaumeGomez rustdoc: render bounds of cross-crate GAT params Follow-up to rust-lang#102439. Render the trait bounds of type parameters of cross-crate (generic) associated types. `````@rustbot````` label T-rustdoc A-cross-crate-reexports r? `````@GuillaumeGomez`````
Member
Member
|
Sounds like a good idea. I'm +1 for this. cc @rust-lang/rustdoc |
Aaron1011
pushed a commit
to Aaron1011/rust
that referenced
this pull request
Jan 6, 2023
…te-hrtbs-properly, r=GuillaumeGomez rustdoc: render more cross-crate HRTBs properly Follow-up to rust-lang#102439. Render the `for<>` parameter lists of cross-crate higher-rank trait bounds (in where-clauses and in `impl Trait`). I've added a new field `bound_params` to `clean::WherePredicate::EqPredicate` (mirroring its sibling variant `BoundPredicate`). However, I had to box the existing fields since `EqPredicate` used to be the largest variant (128 bytes on 64-bit systems) and it would only have gotten bigger). Not sure if you like that approach. As an alternative, I could pass the uncleaned `ty::Predicate` alongside the cleaned `WherePredicate` to the various re-sugaring methods (similar to what `clean::AutoTraitFinder::param_env_to_generics` does). I haven't yet added the HTML & JSON rendering code for the newly added `bound_params` field since I am waiting for your opinion. Those two rendering code paths should actually be unreachable in practice given we re-sugar all(?) equality predicates to associated type bindings (and arbitrary equality predicates are not part of the Rust surface language at the time of this writing). If you agree with storing `bound_params` in `EqPredicate`, I think I can use it to greatly simplify the `clean::auto_trait` module (by also using `simplify::merge_bounds`). Maybe I can do that in any case though. `@rustbot` label T-rustdoc A-cross-crate-reexports r? `@GuillaumeGomez`
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Previously, we would only ever re-sugar cross-crate predicates like
Type: Trait, <Type as Trait>::Name == RhstoType: Trait<Name = Rhs>if theTypewas a generic parameter likeSelforT. With this PR,Typecan be any type.Most notably, this means that we now re-sugar predicates involving associated types (where
Typeis of the formSelf::Name) which are then picked up by the pre-existing logic that re-sugars them into bounds. As a result of that, the associated typeIntoIterofstd'sIntoIteratortrait (re-exported fromcore) is no longer rendered as:but as one would expect:
type IntoIter: Iterator<Item = Self::Item>;.Cross-crate closure bounds like
F: Fn(i32) -> boolare now also rendered properly (previously, the return type (Self::Output) would not be rendered and we would show the underlying equality predicate).Fixes #77763.
Fixes #84579.
Fixes #102142.
@rustbot label T-rustdoc A-cross-crate-reexports
r? rustdoc