-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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: re-sugar more cross-crate trait bounds #102439
rustdoc: re-sugar more cross-crate trait bounds #102439
Conversation
Looks really good! Please ping me once you have some answers about the empty |
f146915
to
a540234
Compare
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. |
Then let's go! @bors r+ rollup |
…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
…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`
…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`
…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``
…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```
…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````
…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`````
Sounds like a good idea. I'm +1 for this. cc @rust-lang/rustdoc |
…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`
Previously, we would only ever re-sugar cross-crate predicates like
Type: Trait, <Type as Trait>::Name == Rhs
toType: Trait<Name = Rhs>
if theType
was a generic parameter likeSelf
orT
. With this PR,Type
can be any type.Most notably, this means that we now re-sugar predicates involving associated types (where
Type
is 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 typeIntoIter
ofstd
'sIntoIterator
trait (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) -> bool
are 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