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

overlook overflows in rustdoc trait solving #54199

Merged
merged 5 commits into from
Sep 26, 2018

Conversation

nikomatsakis
Copy link
Contributor

Context:

The new rustdoc "auto trait" feature walks across impls and tries to run trait solving on them with a lot of unconstrained variables. This is prone to overflows. These overflows used to cause an ICE because of a caching bug (fixed in this PR). But even once that is fixed, it means that rustdoc causes an overflow rather than generating docs.

This PR therefore adds a new helper that propagates the overflow error out. This requires rustdoc to then decide what to do when it encounters such an overflow: technically, an overflow represents neither "yes" nor "no", but rather a failure to make a decision. I've decided to opt on the side of treating this as "yes, implemented", since rustdoc already takes an optimistic view. This may prove to include too many items, but I suspect not.

We could probably reduce the rate of overflows by unifying more of the parameters from the impl -- right now we only seem to consider the self type. Moreover, in the future, as we transition to Chalk, overflow errors are expected to just "go away" (in some cases, though, queries might return an ambiguous result).

Fixes #52873

cc @QuietMisdreavus -- this is the stuff we were talking about earlier
cc @GuillaumeGomez -- this supersedes #53687

@rust-highfive
Copy link
Collaborator

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 13, 2018
@nikomatsakis
Copy link
Contributor Author

Er, dang it, I should try to make a test for this. Now that I know what's going wrong I may be able to do it.

@nikomatsakis nikomatsakis changed the title overlook overflows in rustdoc trait solving [WIP] overlook overflows in rustdoc trait solving Sep 13, 2018
@GuillaumeGomez
Copy link
Member

Oh this is perfect! Thanks a lot!

On rustdoc side, it'll be "easy". I already have something in mind: if we get an overflow, we just continue to check if there is an other matching trait, if not, then we consider this one was a matching one. How does that sound for you?

@nikomatsakis
Copy link
Contributor Author

On rustdoc side, it'll be "easy". I already have something in mind: if we get an overflow, we just continue to check if there is an other matching trait, if not, then we consider this one was a matching one. How does that sound for you?

I'm not sure I understand exactly what you are proposing. Do you mean "continue to look for any other matching impl"?

@eddyb
Copy link
Member

eddyb commented Sep 13, 2018

r=me with tests added

@GuillaumeGomez
Copy link
Member

@nikomatsakis Yes I do! (sorry for the answer delay...)

@nikomatsakis
Copy link
Contributor Author

Argh. So I spent a while trying to reproduce this error with a self-contained test case but I've failed thus far.

@nikomatsakis
Copy link
Contributor Author

I guess I will start by paring down the existing failure.

@nikomatsakis nikomatsakis changed the title [WIP] overlook overflows in rustdoc trait solving overlook overflows in rustdoc trait solving Sep 25, 2018
@nikomatsakis
Copy link
Contributor Author

@GuillaumeGomez
Copy link
Member

Like I said: seems to appear starting a certain number of possibilities. Thanks a lot in any case!

@nikomatsakis
Copy link
Contributor Author

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Sep 25, 2018

📌 Commit a3997f7 has been approved by eddyb

@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 Sep 25, 2018
@bors
Copy link
Contributor

bors commented Sep 26, 2018

⌛ Testing commit a3997f7 with merge 492e48d8d0f4de114711e13c81dd0e4e10bd3d82...

@bors
Copy link
Contributor

bors commented Sep 26, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 26, 2018
@bors bors merged commit a3997f7 into rust-lang:master Sep 26, 2018
@QuietMisdreavus
Copy link
Member

The linked issue is still occurring on beta; should we backport this PR?

@GuillaumeGomez
Copy link
Member

Didn't you disable blanket impls doc generation on beta? If so, it shouldn't be happening... Otherwise, it means the bug was not from there and that we should backport this pr and re-enable blanket impl doc generation.

@QuietMisdreavus
Copy link
Member

I disabled it in beta, right before it was promoted to stable. Then a new beta was created, so the problem still exists. See the discussion starting at #53687 (comment).

@GuillaumeGomez
Copy link
Member

Weird...

@QuietMisdreavus QuietMisdreavus added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. stable-nominated Nominated for backporting to the compiler in the stable channel. labels Oct 25, 2018
@QuietMisdreavus
Copy link
Member

QuietMisdreavus commented Oct 25, 2018

@rust-lang/rustdoc Since this never got a beta backport, now that ICE is on stable. I've gotten a couple confirmations that 1.30.0 fails to build docs for typenum. If the release team decides to publish a point release, should we backport this?

@rfcbot poll [T-rustdoc] Stable backport?

@QuietMisdreavus
Copy link
Member

If it helps the decision, someone was able to get this branch cleanly rebased onto the stable branch, so it should work out. stable...joelgallant:predicate_may_hold-failure

@QuietMisdreavus
Copy link
Member

QuietMisdreavus commented Oct 25, 2018

Urf, trying to get the rfcbot poll to work. One last try, then i'm switching to manual ticky-boxes...

Here are some manual check-boxes for the rustdoc team, so we have some kind of official record-keeping of actually coming together for the decision. The question, once again, is Should we backport this to stable, if a point release is put together? Please check your box if you agree or comment in this issue with your thoughts.

@QuietMisdreavus
Copy link
Member

ping @rust-lang/rustdoc, i manually edited checkboxes into the previous comment

@pietroalbini pietroalbini added the stable-accepted Accepted for backporting to the compiler in the stable channel. label Nov 1, 2018
@pietroalbini
Copy link
Member

There seems to be consensus from the rustdoc team, marking this as stable-accepted.

Mark-Simulacrum pushed a commit to Mark-Simulacrum/rust that referenced this pull request Nov 7, 2018
…re, r=eddyb

overlook overflows in rustdoc trait solving

Context:

The new rustdoc "auto trait" feature walks across impls and tries to run trait solving on them with a lot of unconstrained variables. This is prone to overflows. These overflows used to cause an ICE because of a caching bug (fixed in this PR). But even once that is fixed, it means that rustdoc causes an overflow rather than generating docs.

This PR therefore adds a new helper that propagates the overflow error out. This requires rustdoc to then decide what to do when it encounters such an overflow: technically, an overflow represents neither "yes" nor "no", but rather a failure to make a decision. I've decided to opt on the side of treating this as "yes, implemented", since rustdoc already takes an optimistic view. This may prove to include too many items, but I *suspect* not.

We could probably reduce the rate of overflows by unifying more of the parameters from the impl -- right now we only seem to consider the self type. Moreover, in the future, as we transition to Chalk, overflow errors are expected to just "go away" (in some cases, though, queries might return an ambiguous result).

Fixes rust-lang#52873

cc @QuietMisdreavus -- this is the stuff we were talking about earlier
cc @GuillaumeGomez -- this supersedes rust-lang#53687
@pietroalbini pietroalbini added stable-accepted Accepted for backporting to the compiler in the stable channel. and removed stable-accepted Accepted for backporting to the compiler in the stable channel. stable-nominated Nominated for backporting to the compiler in the stable channel. labels Nov 7, 2018
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 3, 2024
…t, r=<try>

rustdoc: use the next solver for blanket impl synthesis

Furthermore use an `ObligationCtxt` instead of operating on an `InferCtxt` directly and don't drop the obligations generated by the type relating (fixes a FIXME).

Originally I just wanted to submit the infcx→ocx change. However, that regressed `tests/rustdoc-ui/ice-blanket-impl-52873.rs` (pass→overflow error) because with `ocx.select_where_possible` we would no longer suppress / defatalize (canonical) overflow errors on the last obligation we register. CC rust-lang#54199 which introduced that special case. Obviously in the next solver overflows are non-fatal incl. `ice-blanket-impl-52873.rs`. Hence the switch now.

Note that I wanted to hold off on switching to the new solver since it makes rust-lang#114891 go from long I-compiletime to I-compilemem + I-hang + eventual death by the OOM killer. So I don't know maybe we should block this PR on me finding a rustc reproducer for the rustdoc issue rust-lang#114891 (this is on my agenda) to be able to properly investigate the underlying next-solver issue.
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 15, 2024
…t, r=<try>

rustdoc: use the next solver for blanket impl synthesis

Furthermore use an `ObligationCtxt` instead of operating on an `InferCtxt` directly and don't drop the obligations generated by the type relating.

Originally I just wanted to submit the infcx→ocx change. However, that regressed `tests/rustdoc-ui/ice-blanket-impl-52873.rs` (pass→overflow error) because with `ocx.select_where_possible` we would no longer suppress / defatalize (canonical) overflow errors. CC rust-lang#54199 which introduced that special case. Obviously in the next solver overflows are non-fatal incl. `ice-blanket-impl-52873.rs`. Hence the switch now.

~~Note that I wanted to hold off on switching to the new solver since it makes rust-lang#114891 go from long I-compiletime to I-compilemem + I-hang + eventual death by the OOM killer. So I don't know maybe we should block this PR on me finding a rustc reproducer for the rustdoc issue rust-lang#114891 (this is on my agenda) to be able to properly investigate the underlying next-solver issue.~~

Fixes rust-lang#114891.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. stable-accepted Accepted for backporting to the compiler in the stable channel. 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.

ICE when running cargo doc on typenum at librustc/traits/structural_impls.rs:178
7 participants