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

Ensure that Rustdoc discovers all necessary auto trait bounds #55318

Merged
merged 4 commits into from
Dec 7, 2018

Conversation

Aaron1011
Copy link
Member

Fixes #50159

This commit makes several improvements to AutoTraitFinder:

  • Call infcx.resolve_type_vars_if_possible before processing new
    predicates. This ensures that we eliminate inference variables wherever
    possible.
  • Process all nested obligations we get from a vtable, not just ones
    with depth=1.
    • The 'depth=1' check was a hack to work around issues processing
      certain predicates. The other changes in this commit allow us to
      properly process all predicates that we encounter, so the check is no
      longer necessary,
  • Ensure that we only display predicates without inference variables
    to the user, and only attempt to unify predicates that have an
    inference variable as their type.

Additionally, the internal helper method is_of_param now operates
directly on a type, rather than taking a Substs. This allows us to use
the 'self_ty' method, rather than directly dealing with Substs.

@rust-highfive
Copy link
Collaborator

r? @estebank

(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 Oct 24, 2018
@Aaron1011
Copy link
Member Author

r? @GuillaumeGomez

@kennytm kennytm changed the title Ensure that Rusdoc discovers all necessary auto trait bounds Ensure that Rustdoc discovers all necessary auto trait bounds Oct 24, 2018
@GuillaumeGomez
Copy link
Member

Thanks a lot! However, considering that it changes things in librustc, I'll let someone from the @rust-lang/compiler team review it.

@eddyb
Copy link
Member

eddyb commented Nov 5, 2018

r? @nikomatsakis

@nikomatsakis
Copy link
Contributor

Sorry for being slow-ish, will get on this this week =)

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

Changes all seem good. I'm game to r+ but I have a few questions about the underlying logic.

let substs = &p.skip_binder().trait_ref.substs;
if self.is_of_param(p.skip_binder().self_ty())
&& !only_projections
&& is_new_pred {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we check for inference variables for the other parts of p?

Copy link
Member Author

Choose a reason for hiding this comment

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

That was an oversight on my part - I intended to check all of the parameters in substs, but forgot to change it. I've pushed a new commit fixing it.


if self.is_of_param(substs) && !only_projections && is_new_pred {
self.add_user_pred(computed_preds, predicate);
}
predicates.push_back(p.clone());
Copy link
Contributor

Choose a reason for hiding this comment

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

Pre-existing, but can you explain to me why this adds a user-predicate (above) and then still pushes p back onto the list to be selected again?

Copy link
Member Author

Choose a reason for hiding this comment

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

Selecting p might result in other predicates (e.g. TypeOutlives or RegionOutlives) that are necessary for FulfillmentContext.select_all_or_error to succeed.

In general, AutoTraitFinder always tries to drive select all the way to the end. A subset of the predicates that it finds along the way are suitable for displaying to a user (e.g. rendering in docs), which we track separately.

@Aaron1011
Copy link
Member Author

Once rust-lang/crater#366 is deployed, it might be useful to do a Crater rustdoc run with this PR.

@Aaron1011
Copy link
Member Author

@nikomatsakis: Are there any other changes that you'd like me to make?

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

I'm happy but if you want to do a crater run, that sounds fine to me. I'm not sure if you can do rustdoc crater runs, I guess @pietroalbini would know

@pietroalbini
Copy link
Member

Yeah, it's possible, just use mode=rustdoc.

@Aaron1011
Copy link
Member Author

@nikomatsakis @pietroalbini: I don't have permission to start a crater run - can one of you start one?

@Mark-Simulacrum
Copy link
Member

Since I didn't see a try build here yet... @bors try for crater

@bors
Copy link
Contributor

bors commented Nov 27, 2018

⌛ Trying commit 69e82c1 with merge f5a0bd7...

bors added a commit that referenced this pull request Nov 27, 2018
Ensure that Rustdoc discovers all necessary auto trait bounds

Fixes #50159

This commit makes several improvements to AutoTraitFinder:

* Call infcx.resolve_type_vars_if_possible before processing new
predicates. This ensures that we eliminate inference variables wherever
possible.
* Process all nested obligations we get from a vtable, not just ones
with depth=1.
  * The 'depth=1' check was a hack to work around issues processing
certain predicates. The other changes in this commit allow us to
properly process all predicates that we encounter, so the check is no
longer necessary,
* Ensure that we only display predicates *without* inference variables
to the user, and only attempt to unify predicates that *have* an
inference variable as their type.

Additionally, the internal helper method is_of_param now operates
directly on a type, rather than taking a Substs. This allows us to use
the 'self_ty' method, rather than directly dealing with Substs.
@bors
Copy link
Contributor

bors commented Nov 27, 2018

☀️ Test successful - status-travis
State: approved= try=True

@pietroalbini
Copy link
Member

@craterbot run start=master#6bfb46e4ac9a2704f06de1a2ff7a4612cd70c8cb end=try#f5a0bd723553ea4b7556bd7087b9f0919cafb483 mode=rustdoc

@craterbot
Copy link
Collaborator

👌 Experiment pr-55318 created and queued.
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 27, 2018
@craterbot
Copy link
Collaborator

🚧 Experiment pr-55318 is now running on agent aws-2.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🎉 Experiment pr-55318 is completed!
📰 Open the full report.

⚠️ If you notice any spurious failure please add them to the blacklist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot removed the S-waiting-on-crater Status: Waiting on a crater run to be completed. label Nov 28, 2018
@pietroalbini
Copy link
Member

@craterbot run start=master#147e60c5f89cfa2d3ffc247413956a37582c98e7 end=try#f86f76f89ea2b1ccbfb3741962ec2029d878a389 mode=rustdoc

@craterbot
Copy link
Collaborator

👌 Experiment pr-55318-1 created and queued.
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 30, 2018
@craterbot
Copy link
Collaborator

🚧 Experiment pr-55318-1 is now running on agent aws-1.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🎉 Experiment pr-55318-1 is completed!
📰 Open the full report.

⚠️ If you notice any spurious failure please add them to the blacklist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Dec 2, 2018
@Aaron1011
Copy link
Member Author

The one 'regression' appears spurious.

@nikomatsakis: I believe this is ready to merge.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Dec 6, 2018

📌 Commit 9139374 has been approved by nikomatsakis

@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 Dec 6, 2018
@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Dec 6, 2018

💡 This pull request was already approved, no need to approve it again.

@bors
Copy link
Contributor

bors commented Dec 6, 2018

📌 Commit 9139374 has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Dec 6, 2018

⌛ Testing commit 9139374 with merge 5182cc1...

bors added a commit that referenced this pull request Dec 6, 2018
…matsakis

Ensure that Rustdoc discovers all necessary auto trait bounds

Fixes #50159

This commit makes several improvements to AutoTraitFinder:

* Call infcx.resolve_type_vars_if_possible before processing new
predicates. This ensures that we eliminate inference variables wherever
possible.
* Process all nested obligations we get from a vtable, not just ones
with depth=1.
  * The 'depth=1' check was a hack to work around issues processing
certain predicates. The other changes in this commit allow us to
properly process all predicates that we encounter, so the check is no
longer necessary,
* Ensure that we only display predicates *without* inference variables
to the user, and only attempt to unify predicates that *have* an
inference variable as their type.

Additionally, the internal helper method is_of_param now operates
directly on a type, rather than taking a Substs. This allows us to use
the 'self_ty' method, rather than directly dealing with Substs.
@bors
Copy link
Contributor

bors commented Dec 7, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 5182cc1 to master...

@bors bors merged commit 9139374 into rust-lang:master Dec 7, 2018
@pietroalbini pietroalbini added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. beta-nominated Nominated for backporting to the compiler in the beta channel. labels Jan 3, 2019
@pietroalbini
Copy link
Member

Ping @rust-lang/rustdoc, this PR is a prerequisite for backporting #56838, do you want to accept it for backport on beta?

@QuietMisdreavus QuietMisdreavus added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Jan 3, 2019
@QuietMisdreavus
Copy link
Member

Accepting beta nomination for the same reasons as #56838.

@pietroalbini pietroalbini removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jan 3, 2019
bors added a commit that referenced this pull request Jan 4, 2019
[beta] Rollup backports

Cherry-picked:

* #57053: Fix alignment for array indexing
* #57181: resolve: Fix another ICE in import validation
* #57185: resolve: Fix one more ICE in import validation
* #57282: Wf-check the output type of a function in MIR-typeck
* #55318: Ensure that Rustdoc discovers all necessary auto trait bounds
* #56838: Call poly_project_and_unify_type on types that contain inference types

Rolled up:

* #57300: [beta] Update RLS to include 100% CPU on hover bugfix
* #57301: beta: bootstrap from latest stable (1.31.1)
* #57292: [BETA] Update cargo

r? @ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. 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.

rustdoc panic when trying to build docs