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

Combine ty::Projection and ty::Opaque into ty::Alias #104986

Merged
merged 11 commits into from
Dec 14, 2022

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Nov 27, 2022

Implements rust-lang/types-team#79.

This PR consolidates ty::Projection and ty::Opaque into a single ty::Alias, with an AliasKind and AliasTy type (renamed from ty::ProjectionTy, which is the inner data of ty::Projection) defined as so:

enum AliasKind {
  Projection,
  Opaque,
}

struct AliasTy<'tcx> {
  def_id: DefId,
  substs: SubstsRef<'tcx>,
}

Since we don't have access to TyCtxt in type flags computation, and because repeatedly calling DefKind on the def-id is expensive, these two types are distinguished with ty::AliasKind, conveniently glob-imported into ty::{Projection, Opaque}. For example:

  match ty.kind() {
-   ty::Opaque(..) => 
+   ty::Alias(ty::Opaque, ..) => {}
    _ => {}
  }

This PR also consolidates match arms that treated ty::Opaque and ty::Projection identically.

r? @ghost

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 27, 2022
@rust-log-analyzer

This comment has been minimized.

@compiler-errors compiler-errors force-pushed the opaques branch 3 times, most recently from 9892bfb to ffa4220 Compare November 27, 2022 18:24
@rust-log-analyzer

This comment has been minimized.

Copy link
Contributor

@cjgillot cjgillot left a comment

Choose a reason for hiding this comment

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

I wonder what are the next steps. Can this be used to integrate in-trait opaques as a variant of AliasKind?

compiler/rustc_hir_typeck/src/cast.rs Outdated Show resolved Hide resolved
compiler/rustc_infer/src/infer/error_reporting/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_infer/src/infer/freshen.rs Outdated Show resolved Hide resolved
compiler/rustc_infer/src/infer/opaque_types.rs Outdated Show resolved Hide resolved
compiler/rustc_symbol_mangling/src/legacy.rs Outdated Show resolved Hide resolved
compiler/rustc_traits/src/chalk/lowering.rs Outdated Show resolved Hide resolved
compiler/rustc_type_ir/src/sty.rs Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Nov 28, 2022

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

@compiler-errors compiler-errors marked this pull request as ready for review December 6, 2022 03:38
@rustbot
Copy link
Collaborator

rustbot commented Dec 6, 2022

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

Some changes occurred in need_type_info.rs

cc @lcnr

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@compiler-errors
Copy link
Member Author

I think this is ready

r? types

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Dec 6, 2022

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

Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

r=me with some nits and a clean perf run

compiler/rustc_hir_analysis/src/check/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/fast_reject.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/fast_reject.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/fast_reject.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/fast_reject.rs Outdated Show resolved Hide resolved
compiler/rustc_trait_selection/src/traits/project.rs Outdated Show resolved Hide resolved
@oli-obk
Copy link
Contributor

oli-obk commented Dec 13, 2022

@bors p=1 bitrotty

@bors
Copy link
Contributor

bors commented Dec 13, 2022

⌛ Trying commit 99417d5 with merge ad35b8e377db9f8fa1364750ed99d283bc52b2f2...

@bors
Copy link
Contributor

bors commented Dec 13, 2022

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ad35b8e377db9f8fa1364750ed99d283bc52b2f2): comparison URL.

Overall result: ❌ regressions - ACTION NEEDED

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-perf +perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.1% [1.0%, 1.1%] 2
Regressions ❌
(secondary)
2.1% [0.9%, 2.7%] 7
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.1% [1.0%, 1.1%] 2

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.2% [-2.2%, -2.2%] 1
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Dec 13, 2022
@compiler-errors
Copy link
Member Author

This looks like the same exact noisy crates that we saw in #105350 (comment)

@oli-obk
Copy link
Contributor

oli-obk commented Dec 13, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Dec 13, 2022

📌 Commit 99417d5 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. labels Dec 13, 2022
@bors
Copy link
Contributor

bors commented Dec 14, 2022

⌛ Testing commit 99417d5 with merge 918d0ac...

@bors
Copy link
Contributor

bors commented Dec 14, 2022

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

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (918d0ac): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
3.6% [3.3%, 3.9%] 2
Regressions ❌
(secondary)
1.6% [1.6%, 1.6%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.6% [3.3%, 3.9%] 2

Cycles

This benchmark run did not return any relevant results for this metric.

@rustbot rustbot removed the perf-regression Performance regression. label Dec 14, 2022
celinval added a commit to celinval/kani-dev that referenced this pull request Jan 24, 2023
celinval added a commit to model-checking/kani that referenced this pull request Mar 8, 2023
Upgrade our toolchain to `nightly-2023-01-23`. The changes here are related to the following changes:
- rust-lang/rust#104986
- rust-lang/rust#105657
- rust-lang/rust#105603
- rust-lang/rust#105613
- rust-lang/rust#105977
- rust-lang/rust#104645
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. 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants