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

Properly track ImplObligations #91030

Merged
merged 1 commit into from
Mar 24, 2022

Conversation

estebank
Copy link
Contributor

Instead of probing for all possible impls that could have caused an
ImplObligation, keep track of its DefId and obligation spans for
accurate error reporting.

Follow to #89580. Addresses #89418.

@rust-highfive

This comment was marked as outdated.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 19, 2021
@estebank
Copy link
Contributor Author

estebank commented Nov 19, 2021

Only the last commit is relevant. CC @nagisa, who reviewed the previous PR.

@rust-log-analyzer

This comment has been minimized.

@estebank estebank force-pushed the trait-bounds-are-tricky-2 branch 2 times, most recently from 3ba5d10 to 8765dd5 Compare November 19, 2021 02:24
@petrochenkov
Copy link
Contributor

r? @nagisa

@rust-highfive rust-highfive assigned nagisa and unassigned petrochenkov Nov 19, 2021
@bors

This comment was marked as resolved.

@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 22, 2021
Copy link
Member

@nagisa nagisa left a comment

Choose a reason for hiding this comment

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

I have a hard time finding myself with enough time to give this PR the attention it deserves. Here are a couple comments I wrote last week; but otherwise you may want to consider looking for somebody who is able to dedicate a couple uninterrupted hours to review the PR.

Otherwise I'll just continue looking for an opportunity, but I can't promise it'll come soon.

Comment on lines 22 to 26
note: required because it appears within the type `NoClone`
--> $DIR/supertrait-auto-trait.rs:13:8
|
LL | struct NoClone;
| ^^^^^^^
Copy link
Member

Choose a reason for hiding this comment

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

This reads weird. “because it appears within the type” is typically something one would expect to see for types with fields, but NoClone hasn't any.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Be aware that this is output only possible with feature(auto_traits) enabled.

which is required by `Foo<T>: Bar`
`T: Bar`
which is required by `Foo<T>: Bar`
note: trait bound `T: Bar` was not satisfied because of the requirements of the implementation of `Bar` for `_`
Copy link
Member

Choose a reason for hiding this comment

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

I had to look at this error message for a little while to figure out what

because of the requirements of the implementation of Bar for _

is trying to say here. In particular the wording to me parses to a causation of the following sort:

  • We would use method <&Foo<T> as Bar>::foo, but cannot because there are unsatisfied trait bounds…
  • In particular T: Bar bound from impl<T: Default + Bar> Bar for Foo<T> {} is not satisfied…
  • Which was not satisfied because impl<T: Default + Bar> Bar for Foo<T> {} contains this bound.

whereas what we really mean here is:

  • We would use method <&Foo<T> as Bar>::foo, but cannot because there are unsatisfied trait bounds…
  • In particular T: Bar bound from impl<T: Default + Bar> Bar for Foo<T> {} is not satisfied…
  • Which was not satisfied because T does not implement Bar..

Copy link
Contributor Author

@estebank estebank Dec 3, 2021

Choose a reason for hiding this comment

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

The "duplicated" output is because it points at both Default and Bar bounds as unsatisfied for Bar, while it never talks about T: !Bar beyond the first mention. Would this read better?

error[E0599]: the method `foo` exists for reference `&Foo<T>`, but its trait bounds were not satisfied
  --> $DIR/missing-trait-bounds-for-method-call.rs:14:14
   |
LL | struct Foo<T> {
   | ------------- doesn't satisfy `Foo<T>: Bar`
...
LL |         self.foo();
   |              ^^^ method cannot be called on `&Foo<T>` due to unsatisfied trait bounds
   |
note: trait bound `T: Bar` was not satisfied
  --> $DIR/missing-trait-bounds-for-method-call.rs:10:19
   |
LL | impl<T: Default + Bar> Bar for Foo<T> {}
   |                   ^^^  ---     ------
   |                   |
   |                   unsatisfied trait bound introduced here
note: trait bound `T: Default` was not satisfied
  --> $DIR/missing-trait-bounds-for-method-call.rs:10:9
   |
LL | impl<T: Default + Bar> Bar for Foo<T> {}
   |         ^^^^^^^        ---     ------
   |         |
   |         unsatisfied trait bound introduced here
help: consider restricting the type parameters to satisfy the trait bounds
   |
LL | struct Foo<T> where T: Bar, T: Default {
   |               ++++++++++++++++++++++++

@bors

This comment was marked as resolved.

@estebank
Copy link
Contributor Author

estebank commented Dec 3, 2021

@oli-obk would you have time to take a look at this?

@rust-log-analyzer

This comment has been minimized.

@estebank estebank force-pushed the trait-bounds-are-tricky-2 branch 2 times, most recently from 52760bf to a117cf5 Compare December 3, 2021 01:22
@oli-obk
Copy link
Contributor

oli-obk commented Dec 3, 2021

r? @oli-obk

@rust-highfive rust-highfive assigned oli-obk and unassigned nagisa Dec 3, 2021
@oli-obk

This comment was marked as outdated.

@rust-timer

This comment was marked as outdated.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 3, 2021
@bors

This comment was marked as outdated.

@bors

This comment was marked as outdated.

@rust-timer

This comment was marked as outdated.

@bors
Copy link
Contributor

bors commented Mar 24, 2022

☀️ Try build successful - checks-actions
Build commit: 548649c9868f5cb125e19b7b4b74884aa901a5ae (548649c9868f5cb125e19b7b4b74884aa901a5ae)

@rust-timer
Copy link
Collaborator

Queued 548649c9868f5cb125e19b7b4b74884aa901a5ae with parent 37b55c8, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (548649c9868f5cb125e19b7b4b74884aa901a5ae): comparison url.

Summary: This benchmark run shows 25 relevant regressions 😿 to instruction counts.

  • Arithmetic mean of relevant regressions: 1.7%
  • Largest regression in instruction counts: 3.9% on full builds of projection-caching check

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR led to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf +perf-regression

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Mar 24, 2022
@oli-obk
Copy link
Contributor

oli-obk commented Mar 24, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Mar 24, 2022

📌 Commit 5fd3786 has been approved by oli-obk

@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. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 24, 2022
@bors
Copy link
Contributor

bors commented Mar 24, 2022

⌛ Testing commit 5fd3786 with merge d2df372...

@bors
Copy link
Contributor

bors commented Mar 24, 2022

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 24, 2022
@bors bors merged commit d2df372 into rust-lang:master Mar 24, 2022
@rustbot rustbot added this to the 1.61.0 milestone Mar 24, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (d2df372): comparison url.

Summary: This benchmark run shows 19 relevant regressions 😿 to instruction counts.

  • Arithmetic mean of relevant regressions: 1.9%
  • Largest regression in instruction counts: 3.8% on full builds of projection-caching check

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression

@pnkfelix
Copy link
Member

Visiting for weekly performance triage.

The hit here was already anticipated. I trust that @oli-obk and @estebank will do what they can to improve performance around obligation causes

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Mar 30, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request May 17, 2022
…estebank

Clean up derived obligation creation

r? `@estebank`

working on fixing the perf regression from rust-lang#91030 (comment)
@estebank estebank deleted the trait-bounds-are-tricky-2 branch November 9, 2023 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.