-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Conversation
r? @estebank (rust_highfive has picked a reviewer for you, use r? to override) |
Thanks a lot! However, considering that it changes things in librustc, I'll let someone from the @rust-lang/compiler team review it. |
Sorry for being slow-ish, will get on this this week =) |
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Once rust-lang/crater#366 is deployed, it might be useful to do a Crater |
@nikomatsakis: Are there any other changes that you'd like me to make? |
There was a problem hiding this 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
Yeah, it's possible, just use |
@nikomatsakis @pietroalbini: I don't have permission to start a crater run - can one of you start one? |
Since I didn't see a try build here yet... @bors try for crater |
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.
☀️ Test successful - status-travis |
@craterbot run start=master#6bfb46e4ac9a2704f06de1a2ff7a4612cd70c8cb end=try#f5a0bd723553ea4b7556bd7087b9f0919cafb483 mode=rustdoc |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🎉 Experiment
|
@craterbot run start=master#147e60c5f89cfa2d3ffc247413956a37582c98e7 end=try#f86f76f89ea2b1ccbfb3741962ec2029d878a389 mode=rustdoc |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🎉 Experiment
|
The one 'regression' appears spurious. @nikomatsakis: I believe this is ready to merge. |
@bors r+ |
📌 Commit 9139374 has been approved by |
@bors r+ |
💡 This pull request was already approved, no need to approve it again.
|
📌 Commit 9139374 has been approved by |
…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.
☀️ Test successful - status-appveyor, status-travis |
Ping @rust-lang/rustdoc, this PR is a prerequisite for backporting #56838, do you want to accept it for backport on beta? |
Accepting beta nomination for the same reasons as #56838. |
[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
Fixes #50159
This commit makes several improvements to AutoTraitFinder:
predicates. This ensures that we eliminate inference variables wherever
possible.
with depth=1.
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,
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.