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

Track implicit Sized obligations in type params #98816

Merged
merged 3 commits into from
Jul 9, 2022

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Jul 2, 2022

When we evaluate ty::GenericPredicates we introduce the implicit
Sized predicate of type params, but we do so with only the Predicate
its Span as context, we don't have an Obligation or
ObligationCauseCode we could influence. To try and carry this
information through, we add a new field to ty::GenericPredicates that
tracks both which predicates come from a type param and whether that
param has any bounds already (to use in suggestions).

We also suggest adding a ?Sized bound if appropriate on E0599.

Address part of #98539.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 2, 2022
@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(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 Jul 2, 2022
@estebank
Copy link
Contributor Author

estebank commented Jul 2, 2022

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 2, 2022
@bors
Copy link
Contributor

bors commented Jul 2, 2022

⌛ Trying commit 35c8de37a381d04518bc264b7ce77540e60248e2 with merge ad41a769c55008b2c294b5a07fecd82cb7dcba8c...

@estebank
Copy link
Contributor Author

estebank commented Jul 2, 2022

r? @oli-obk

@rust-highfive rust-highfive assigned oli-obk and unassigned petrochenkov Jul 2, 2022
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jul 2, 2022

💔 Test failed - checks-actions

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 2, 2022
@rust-log-analyzer

This comment has been minimized.

@estebank
Copy link
Contributor Author

estebank commented Jul 2, 2022

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@bors
Copy link
Contributor

bors commented Jul 2, 2022

⌛ Trying commit 8d080c6627d392ebb85974416bf97d00c5931105 with merge 4b74390cde4e98d80560abd60516653939311c30...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jul 2, 2022

☀️ Try build successful - checks-actions
Build commit: 4b74390cde4e98d80560abd60516653939311c30 (4b74390cde4e98d80560abd60516653939311c30)

@rust-timer
Copy link
Collaborator

Queued 4b74390cde4e98d80560abd60516653939311c30 with parent 750d6f8, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (4b74390cde4e98d80560abd60516653939311c30): comparison url.

Instruction count

  • Primary benchmarks: 😿 relevant regressions found
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions 😿
(primary)
0.6% 2.1% 58
Regressions 😿
(secondary)
1.1% 3.5% 28
Improvements 🎉
(primary)
-0.2% -0.2% 3
Improvements 🎉
(secondary)
-0.4% -0.6% 8
All 😿🎉 (primary) 0.6% 2.1% 61

Max RSS (memory usage)

Results
  • Primary benchmarks: 😿 relevant regressions found
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions 😿
(primary)
1.9% 6.4% 11
Regressions 😿
(secondary)
2.4% 3.4% 5
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
-2.2% -2.2% 1
All 😿🎉 (primary) 1.9% 6.4% 11

Cycles

Results
  • Primary benchmarks: 😿 relevant regression found
  • Secondary benchmarks: 🎉 relevant improvement found
mean1 max count2
Regressions 😿
(primary)
2.8% 2.8% 1
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
-3.3% -3.3% 1
All 😿🎉 (primary) 2.8% 2.8% 1

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 may lead 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

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@rustbot rustbot added perf-regression Performance regression. 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 Jul 3, 2022
@oli-obk
Copy link
Contributor

oli-obk commented Jul 4, 2022

The keccak regression is essentially just

<ObligationForest<PendingPredicateObligation>>::process_obligations::<FulfillProcessor, Outcome<PendingPredicateObligation, FulfillmentErrorCode>>

I'm guessing this is a caching issue now, as we can't ignore the new information like we could if it were part of the obligation cause. A hacky way forward would be to remove (canonicalize?) this information when invoking queries. But my root concern (adding such information to the predicate when it isn't actually used to make language decisions) still stands, and I don't have an obviously good solution for the problem here.

One thing we could try is to add a magical trait ExplicitlySized: Sized that we add in addition to explicit Sized bounds. When diagnostics are trying to add Sized bounds, we can check for ExplicitlySized and avoid suggesting Sized in that case.

Hmm... one thing I don't know if we talked about: have you attempted looking at the HIR to figure out if there's a Sized bound already at the time of diagnostic reporting?

@estebank
Copy link
Contributor Author

estebank commented Jul 6, 2022

There we go hir hiking :)

@bors

This comment was marked as resolved.

@rust-log-analyzer

This comment was marked as outdated.

ty::Adt(def, _) if def.did().is_local() => {
tcx.def_ident_span(def.did()).map(|span| span)
}
ty::Adt(def, _) => Some(tcx.def_span(def.did())),
Copy link
Contributor

Choose a reason for hiding this comment

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

this causes a lot of ui test noise and I don't think any of it is actually an improvement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can revert.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

It still seems to be there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only part of the change that is still there is the removal of the unnecessary map call, the match guard is now present.

Copy link
Contributor

Choose a reason for hiding this comment

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

you also changed def_ident_span to def_span, which now points to the entire item, which is what I meant originally 😆 I didn't even notice the match guard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it to be consistent with other places where we use def_span so that multiple span labels pointing at the same thing don't stagger. After a recent change def_span points only at the signature and not the whole item, so it is suitable to use now. I didn't move all to be def_ident_span because that would break the derive suggestions (I'm planning on reducing the span in the future, but not in this PR).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an example of what I'm saying:

error[E0599]: the method `get` exists for struct `Victim<'_, Self>`, but its trait bounds were not satisfied
  --> $DIR/impl-derived-implicit-sized-bound.rs:31:19
   |
LL | struct Victim<'a, T: Perpetrator + ?Sized>
   | ------------------------------------------
   | |
   | method `get` not found for this struct
   | doesn't satisfy `Victim<'_, Self>: VictimTrait`

Without the change the label for "method get not found for this struct" would point at the ident, making the visual presentation a bit less... clean.

Suggest adding a `?Sized` bound if appropriate on E0599 by inspecting
the HIR Generics. (Fix rust-lang#98539)
@oli-obk
Copy link
Contributor

oli-obk commented Jul 8, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Jul 8, 2022

📌 Commit 385c793 has been approved by oli-obk

It is now in the queue for this repository.

@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 Jul 8, 2022
@estebank estebank removed the perf-regression Performance regression. label Jul 8, 2022
@bors
Copy link
Contributor

bors commented Jul 8, 2022

⌛ Testing commit 385c793 with merge 47575bb...

@bors
Copy link
Contributor

bors commented Jul 9, 2022

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 9, 2022
@bors bors merged commit 47575bb into rust-lang:master Jul 9, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 9, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (47575bb): comparison url.

Instruction count

  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 😿 relevant regressions found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
1.7% 2.0% 4
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) N/A N/A 0

Max RSS (memory usage)

Results
  • Primary benchmarks: 😿 relevant regressions found
  • Secondary benchmarks: 😿 relevant regression found
mean1 max count2
Regressions 😿
(primary)
1.2% 2.2% 2
Regressions 😿
(secondary)
4.5% 4.5% 1
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) 1.2% 2.2% 2

Cycles

Results
  • Primary benchmarks: mixed results
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions 😿
(primary)
2.2% 2.3% 2
Regressions 😿
(secondary)
3.4% 4.4% 4
Improvements 🎉
(primary)
-3.0% -3.0% 1
Improvements 🎉
(secondary)
-3.0% -3.3% 2
All 😿🎉 (primary) 0.5% -3.0% 3

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

@rustbot label: -perf-regression

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@oli-obk
Copy link
Contributor

oli-obk commented Jul 9, 2022

@rustbot label:perf-regression-triaged

Just noise, #98961 had the same perf diff, just as an improvement

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Jul 9, 2022
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-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.

9 participants