-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Show pending obligations as unsatisfied constraints in report_similar_impl_candidates
#134348
base: master
Are you sure you want to change the base?
Show pending obligations as unsatisfied constraints in report_similar_impl_candidates
#134348
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @wesleywiser (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
The job Click to see the possible cause of the failure (guessed by this bot)
|
From the CI failure, it looks like the patch introduces a lot of redundant hints with constraints that are basically equivalent to the original constraint. I can try to work on hiding pending obligations that match the original. But I'm not quite sure how to do that within |
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 not totally certain what the motivation here is because there's no test and the issue you linked has a pretty large minimization, so I'm not actually sure what the root cause is and whether this is actually the best way to show that information.
Can you try to turn this into a more minimal example to try to explain better what information the compiler is missing in its diagnostics outputs?
Otherwise I'm not totally certain we can give good feedback on the approach in this PR, especially because making a totally new way of reporting unsatisfied predicates on a pretty common codepath (for unsatisfied impls) seems a bit excessive on first glance.
@@ -17,6 +17,8 @@ use crate::traits::Obligation; | |||
pub enum ScrubbedTraitError<'tcx> { | |||
/// A real error. This goal definitely does not hold. | |||
TrueError, | |||
// A select error with pending obligations | |||
Select(PredicateObligations<'tcx>), |
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 understand that it's not really documented, but this is antithetical to the design of ScrubbedTraitError
. That type should be very lightweight.
Fixes: #134346
Summary
This PR attempts to fix the issue in #134346, by additional
help
hints for each unsatisfied indirect constraint inside a blanket implementation.Details
To provide the extra information, a new variant
Select(PredicateObligations<'tcx>)
is added toScrubbedTraitError<'tcx>
to extract thepending_obligations
returned fromselect_where_possible
. Then insidereport_similar_impl_candidates
, we iterate through every pending obligation in the errors, and print them out as ahelp
hint.Potential Issues
This is my first contribution to the Rust compiler project. I'm not sure of the best way to present the error messages, or handle them anywhere else in the codebase. If there are better ways to implement the improvement, I'm happy to modify the PR according to the suggestions.
An unresolved issue here is that the fix is only implemented for the old Rust trait solver. Compared to
OldSolverError
, I don't see thepending_obligations
field to be present insideNextSolverError
. So I'm unsure of the best way to keep this forward compatible with the upcoming trait solver.I'm also not sure if the fix here would produce too noisy errors outside of my specific use case. When I test this fix with more complex projects that I have, the error messages may contain many unresolved constraints. However when scanning through all items, I determined that none of the listed unresolved constraints should be considered uninformative noise. Hence, I do think that it is essential to have all unresolved constraints listed in the error message.