Skip to content

Register normalization obligations instead of immediately normalizing in opaque type instantiation #89045

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

Merged
merged 6 commits into from
Sep 21, 2021

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Sep 17, 2021

For lazy TAIT we will need to instantiate opaque types from within rustc_infer, which cannot invoke normalization methods (they are in rustc_trait_resolution). So before we move the logic over to rustc_infer, we need make sure no normalization happens anymore. This PR resolves that by just registering normalization obligations and continuing.

This PR is best reviewed commit by commit

I also included f7ad36e which is just an independent cleanup that touches the same code and reduces diagnostics noise a bit

r? @nikomatsakis cc @spastorino

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 17, 2021
use super::InferCtxt;

impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
pub fn infer_projection(
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment please =) What is the purpose of this function?

@nikomatsakis
Copy link
Contributor

r=me once comment is added

@oli-obk
Copy link
Contributor Author

oli-obk commented Sep 18, 2021

@bors r=nikomatsakis

@bors
Copy link
Collaborator

bors commented Sep 18, 2021

📌 Commit fc75914ae52f86e856bb32079caf75dde704bda7 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 Sep 18, 2021
@bors
Copy link
Collaborator

bors commented Sep 18, 2021

☔ The latest upstream changes (presumably #88980) made this pull request unmergeable. Please resolve the merge conflicts.

@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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 18, 2021
@oli-obk
Copy link
Contributor Author

oli-obk commented Sep 20, 2021

@bors try @rust-timer queue

@bors
Copy link
Collaborator

bors commented Sep 20, 2021

🙅 Please do not try after a pull request has been r+ed. If you need to try, unapprove (r-) it first.

@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 Sep 20, 2021
@oli-obk
Copy link
Contributor Author

oli-obk commented Sep 20, 2021

@bors r-

@oli-obk
Copy link
Contributor Author

oli-obk commented Sep 20, 2021

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

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

@bors
Copy link
Collaborator

bors commented Sep 20, 2021

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout lazy_normalization_in_opaque_types (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self lazy_normalization_in_opaque_types --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Auto-merging compiler/rustc_trait_selection/src/opaque_types.rs
CONFLICT (content): Merge conflict in compiler/rustc_trait_selection/src/opaque_types.rs
Automatic merge failed; fix conflicts and then commit the result.

@oli-obk oli-obk force-pushed the lazy_normalization_in_opaque_types branch from fc75914 to afb7472 Compare September 20, 2021 14:16
@oli-obk
Copy link
Contributor Author

oli-obk commented Sep 20, 2021

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

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

@bors
Copy link
Collaborator

bors commented Sep 20, 2021

⌛ Trying commit afb7472 with merge e5e1870d75756ab1996687c3b9ebe7af4122c036...

@bors
Copy link
Collaborator

bors commented Sep 20, 2021

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

@rust-timer
Copy link
Collaborator

Queued e5e1870d75756ab1996687c3b9ebe7af4122c036 with parent db1fb85, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e5e1870d75756ab1996687c3b9ebe7af4122c036): comparison url.

Summary: This change led to small relevant mixed results 🤷 in compiler performance.

  • Small improvement in instruction counts (up to -0.5% on full builds of coercions)
  • Small regression in instruction counts (up to 0.4% on incr-full builds of ctfe-stress-4)

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 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 Sep 20, 2021
@oli-obk
Copy link
Contributor Author

oli-obk commented Sep 20, 2021

looks like codegen noise to me, and this PR should not affect codegen at all, it's purely in the type system

@rustbot label: +perf-regression-triaged

@bors r=nikomatsakis

@bors
Copy link
Collaborator

bors commented Sep 20, 2021

📌 Commit afb7472 has been approved by nikomatsakis

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Sep 20, 2021
@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 Sep 20, 2021
@bors
Copy link
Collaborator

bors commented Sep 21, 2021

⌛ Testing commit afb7472 with merge dda2a0e...

@bors
Copy link
Collaborator

bors commented Sep 21, 2021

☀️ Test successful - checks-actions
Approved by: nikomatsakis
Pushing dda2a0e to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 21, 2021
@bors bors merged commit dda2a0e into rust-lang:master Sep 21, 2021
@rustbot rustbot added this to the 1.57.0 milestone Sep 21, 2021
@oli-obk oli-obk deleted the lazy_normalization_in_opaque_types branch September 21, 2021 13:52
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (dda2a0e): comparison url.

Summary: This benchmark run did not return any relevant changes.

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

@rustbot label: -perf-regression

@rustbot rustbot removed the perf-regression Performance regression. label Sep 21, 2021
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants