Skip to content

Normalize <X as Y>::T for rustdoc - #77467

Merged
bors merged 4 commits into
rust-lang:masterfrom
jyn514:query-docs
Nov 26, 2020
Merged

Normalize <X as Y>::T for rustdoc#77467
bors merged 4 commits into
rust-lang:masterfrom
jyn514:query-docs

Conversation

@jyn514

@jyn514jyn514 commented Oct 2, 2020

Copy link
Copy Markdown
Member
  • Only run for QPath::Resolved with Some self parameter (<X as Y>::T)
  • Fall back to the previous behavior if the path can't be resolved

The first commit is a pure refactor and should probably be reviewed by @GuillaumeGomez. I recommend reviewing the second commit on its own.

Fixes#77459.

r? @eddyb
cc @danielhenrymantilla , @lcnr

@jyn514jyn514 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-trait-system Area: Trait system labels Oct 2, 2020
@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 2, 2020
@jyn514
jyn514force-pushed the query-docs branch 2 times, most recently from a1ad03f to 3a57b53CompareOctober 2, 2020 20:58
@jyn514

jyn514 commented Oct 2, 2020

Copy link
Copy Markdown
MemberAuthor

Look at that beauty 🎉

image

for context, it looked like this before:

image

@GuillaumeGomezGuillaumeGomez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The generated doc is simpler, so I strongly approve this change! Well done. :)

@danielhenrymantilla

Copy link
Copy Markdown
Contributor

Great job, @jyn514 !! 🔥

@jyn514jyn514 added the relnotes Marks issues that should be documented in the release notes of the next release. label Oct 3, 2020
@jyn514

jyn514 commented Oct 6, 2020

Copy link
Copy Markdown
MemberAuthor

Summarizing my conversation with eddyb:

  • Putting this in hir::QPath seems wrong, it will break for cross-crate re-exports. It should go in ty::Projection instead.
  • The ParamEnv for this seems wrong - eddyb thinks that rustdoc needs to track the environment as it goes, the way other lints work:
    fnwith_param_env<F>(&mutself,id: hir::HirId,f:F)
    where
    F:FnOnce(&mutSelf),
    {
    let old_param_env = self.context.param_env;
    self.context.param_env =
    self.context.tcx.param_env(self.context.tcx.hir().local_def_id(id));
    f(self);
    self.context.param_env = old_param_env;
    }

    However I think currently it won't cause ICEs because rustdoc never looks at the type after it's been normalized; clean() isn't going through tcx.

@jyn514
jyn514force-pushed the query-docs branch 2 times, most recently from 0d06449 to c647bcbCompareOctober 16, 2020 01:09
@jyn514

jyn514 commented Oct 16, 2020

Copy link
Copy Markdown
MemberAuthor

This now works for cross-crate re-exports, but does not work for 'partial' normalization like

<Vec<T> as IntoIterator>::IntoIter -> vec::IntoIter<T>

Fixing partial normalization requires actually having a correct ParamEnv, which requires a lot of infrastructure in rustdoc I'm not sure how to write.

@eddyb I know this isn't 100% correct, but do you think it's better than the current situation of no normalization at all? I'm not sure where to start for having a correct ParamEnv :/

@jyn514

Copy link
Copy Markdown
MemberAuthor

Current status: this is blocked on #78082 to get the param context, since otherwise the API is different enough from rustc I wouldn't be convinced it had consistent behavior.

@jyn514jyn514 added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 2, 2020
@jyn514jyn514 added the A-associated-items Area: Associated items (types, constants & functions) label Nov 12, 2020
@jyn514
jyn514force-pushed the query-docs branch 2 times, most recently from 49e8029 to 2833896CompareNovember 23, 2020 04:40
@jyn514

jyn514 commented Nov 23, 2020

Copy link
Copy Markdown
MemberAuthor

This is finally (finally) ready to go 🎉 🎉 🎉

It does need to wait for #79335 and all related PRs to land first, I'll bug Guillaume about those tomorrow. It does not need #78082.

@eddyb the relevant commits are 9b5f5e0 and 2833896.

@jyn514

Copy link
Copy Markdown
MemberAuthor

Some more choice screenshots:

Before:
image

After:
image

@jyn514jyn514 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Nov 23, 2020
@jyn514jyn514 mentioned this pull request Nov 24, 2020
@GuillaumeGomez

Copy link
Copy Markdown
Member

Still looks good to me! Waiting for @eddyb now. :)

@bors

This comment has been minimized.

@oli-obk

Copy link
Copy Markdown
Contributor

r? @oli-obk

@rust-highfiverust-highfive assigned oli-obk and unassigned eddybNov 26, 2020

@oli-obkoli-obk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just a nit, then this lgtm

Comment threadsrc/librustdoc/clean/mod.rs Outdated
... and fix some fuzzy wording in the debug logging.
@jyn514

Copy link
Copy Markdown
MemberAuthor

@bors r=oli-obk

🎉 🎉

@bors

bors commented Nov 26, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit 277bdbc has been approved by oli-obk

@borsbors 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 Nov 26, 2020
@bors

bors commented Nov 26, 2020

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 277bdbc with merge 65ecc48...

@bors

bors commented Nov 26, 2020

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 65ecc48 to master...

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label Nov 26, 2020
@bors
bors merged commit 65ecc48 into rust-lang:masterNov 26, 2020
@rustbotrustbot added this to the 1.50.0 milestone Nov 26, 2020
@jyn514
jyn514 deleted the query-docs branch November 26, 2020 18:58
@jyn514
jyn514 restored the query-docs branch November 27, 2020 14:43
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 27, 2020
Cleanup more of rustdoc
- Use `Item::from_def_id` for StructField
- Use `from_def_id_and_parts` for primitives and keywords
- Take `String` instead of `Symbol` in `from_def_id` - this avoids having to intern then immediately stringify the existing string.
- Remove unused `get_stability` and `get_deprecation`
- Remove unused `attrs` field from `primitives`
- Remove unused `attrs` field from `keywords`
This will probably conflict with rust-lang#79335 and I would prefer for that PR to land first - I'm anxious for rust-lang#77467 to land :)
Makes rust-lang#76998 easier to add.
r? `@GuillaumeGomez`
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 28, 2020
…jyn514
Revert "Normalize `<X as Y>::T` for rustdoc"
Reverts rust-lang#77467 by disabling normalization. See rust-lang#79459; I intend to reland normalization once that's fixed.
r? `@Aaron1011`
cc `@oli-obk` `@GuillaumeGomez`
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 29, 2020
Don't run `resolve_vars_if_possible` in `normalize_erasing_regions`
Neither `@eddyb` nor I could figure out what this was for. I changed it to `assert_eq!(normalized_value, infcx.resolve_vars_if_possible(&normalized_value));` and it passed the UI test suite.
<details><summary>
Outdated, I figured out the issue - `needs_infer()` needs to come _after_ erasing the lifetimes
</summary>
Strangely, if I change it to `assert!(!normalized_value.needs_infer())` it panics almost immediately:
```
query stack during panic:
#0 [normalize_generic_arg_after_erasing_regions] normalizing `<str::IsWhitespace as str::pattern::Pattern>::Searcher`
#1 [needs_drop_raw] computing whether `str::iter::Split<str::IsWhitespace>` needs drop
#2 [mir_built] building MIR for `str::<impl str>::split_whitespace`
#3 [unsafety_check_result] unsafety-checking `str::<impl str>::split_whitespace`
#4 [mir_const] processing MIR for `str::<impl str>::split_whitespace`
#5 [mir_promoted] processing `str::<impl str>::split_whitespace`
rust-lang#6 [mir_borrowck] borrow-checking `str::<impl str>::split_whitespace`
rust-lang#7 [analysis] running analysis passes on this crate
end of query stack
```
I'm not entirely sure what's going on - maybe the two disagree?
</details>
For context, this came up while reviewing rust-lang#77467 (cc `@lcnr).`
Possibly this needs a crater run?
r? `@nikomatsakis`
cc `@matthewjasper`
@jyn514
jyn514 deleted the query-docs branch December 10, 2020 21:34
@jyn514

Copy link
Copy Markdown
MemberAuthor

Since #79469 and #79525, this now requires a feature gate, so removing relnotes.

@jyn514jyn514 removed the relnotes Marks issues that should be documented in the release notes of the next release. label Dec 29, 2020
@fmeasefmease mentioned this pull request May 25, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-associated-itemsArea: Associated items (types, constants & functions)A-trait-systemArea: Trait systemmerged-by-borsThis PR was explicitly merged by bors.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-rustdocRelevant 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.

Query docs show return types as <query_name as QueryConfig<TyCtxt<'tcx>>>::Stored

8 participants

@jyn514@danielhenrymantilla@GuillaumeGomez@bors@oli-obk@eddyb@rust-highfive@rustbot