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: render bounds of cross-crate GAT params #103190

Merged

Conversation

fmease
Copy link
Member

@fmease fmease commented Oct 18, 2022

Follow-up to #102439.
Render the trait bounds of type parameters of cross-crate (generic) associated types.

@rustbot label T-rustdoc A-cross-crate-reexports
r? @GuillaumeGomez

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Oct 18, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 18, 2022
@rustbot rustbot added the A-cross-crate-reexports Area: Documentation that has been re-exported from a different crate label Oct 18, 2022
// as opposed to being located in the where clause.
let predicates = tcx.explicit_predicates_of(assoc_item.def_id).predicates;
let predicates =
tcx.arena.alloc_from_iter(bounds.into_iter().chain(predicates).copied());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to manually merge the result of tcx.explicit_item_bounds and tcx.explicit_predicates_of even though there is a query that already does both, namely tcx.trait_explicit_predicates_and_bounds. However, the latter only works for local definitions (and therefore only accepts LocalDefIds) and we obviously need to be able to handle cross-crate definitions.

@fmease
Copy link
Member Author

fmease commented Oct 19, 2022

Alternatively, I can remove the bound re-sugaring and only keep the explicit_predicates_of change. This means that for type Out14<P: Copy + Eq, Q: ?Sized>; (from the UI test) we would render the following instead:

type Out14<P, Q>
where
    P: Copy + Eq,
    Q: ?Sized

This would be similar to what we currently do for (cross-crate) trait parameters. E.g. trait Tr<T: Eq + Copy> {} renders a where-clause instead of direct bounds.

In any case, as far as I know (and as far as the existing comments vaguely state) there truly is no means to get to know if the user actually wrote the bounds in the where-clause or directly attached to the parameters since this seems to be lost when desugaring, when storing the crate metadata and/or when the data is cleaned. I am not sure which one is the case. Maybe we can reconstruct this piece of information by looking at the spans (if available). No idea.

Just note that this is a well-known shortcoming of rustdoc's cross-crate documentation abilities. Confer several A-cross-crate-reexports issues.

@GuillaumeGomez
Copy link
Member

Apart from my question, looks all good to me, thanks!

@fmease fmease force-pushed the rustdoc-render-bounds-of-cross-crate-gat-params branch from b1d02fe to 2cc4a0a Compare October 19, 2022 16:02
@rustbot rustbot added the A-testsuite Area: The testsuite used to check the correctness of rustc label Oct 19, 2022
@fmease
Copy link
Member Author

fmease commented Oct 19, 2022

ready

@GuillaumeGomez
Copy link
Member

Thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Oct 19, 2022

📌 Commit 2cc4a0a has been approved by GuillaumeGomez

It is now in the queue for this repository.

@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 Oct 19, 2022
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````
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 22, 2022
Rollup of 7 pull requests

Successful merges:

 - rust-lang#102602 (Slightly tweak comments wrt `lint_overflowing_range_endpoint`)
 - rust-lang#103190 (rustdoc: render bounds of cross-crate GAT params)
 - rust-lang#103224 (Allow semicolon after closure within parentheses in macros)
 - rust-lang#103280 ((rust-lang#102929) Implement `String::leak` (attempt 2))
 - rust-lang#103329 (Add a forgotten check for NonNull::new_unchecked's precondition)
 - rust-lang#103346 (Adjust argument type for mutable with_metadata_of (rust-lang#75091))
 - rust-lang#103360 (Reduce false positives in msys2 detection)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 988153c into rust-lang:master Oct 22, 2022
@rustbot rustbot added this to the 1.66.0 milestone Oct 22, 2022
@fmease fmease deleted the rustdoc-render-bounds-of-cross-crate-gat-params branch November 2, 2022 14:34
fmease added a commit to fmease/rust that referenced this pull request Nov 4, 2022
… where-clause to param declaration site

I've overlooked this in rust-lang#103190.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cross-crate-reexports Area: Documentation that has been re-exported from a different crate A-testsuite Area: The testsuite used to check the correctness of rustc 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.

5 participants