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

Uplift the (new solver) canonicalizer into rustc_next_trait_solver #117586

Merged
merged 3 commits into from
Dec 9, 2023

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Nov 4, 2023

Uplifts the new trait solver's canonicalizer into a new crate called rustc_next_trait_solver.

The crate name is literally a bikeshed-avoidance name, so let's not block this PR on that -- renames are welcome later.

There are a host of other changes that were required to make this possible:

  • Expose a ConstTy trait to get the Interner::Ty from a Interner::Const.
  • Expose some constructor methods to construct Bound variants. These are currently methods defined on the interner themselves, but they could be pulled into traits later.
  • Expose a IntoKind trait to turn a Ty/Const/Region into their corresponding *Kinds.
  • Some minor tweaks to other APIs in rustc_type_ir.

The canonicalizer code itself is best reviewed with whitespace ignored.

r? @lcnr

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 4, 2023
@compiler-errors compiler-errors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 4, 2023
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Nov 5, 2023

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

@rust-log-analyzer

This comment has been minimized.

@compiler-errors compiler-errors marked this pull request as ready for review November 22, 2023 23:50
@rustbot
Copy link
Collaborator

rustbot commented Nov 22, 2023

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@compiler-errors compiler-errors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 22, 2023
@compiler-errors compiler-errors changed the title Uplift the (new solver) canonicalizer into rustc_type_ir Uplift the (new solver) canonicalizer into rustc_next_trait_solver Nov 23, 2023
@bors
Copy link
Contributor

bors commented Nov 25, 2023

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

Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

I am fairly unhappy with using Clone instead of Copy. However, r-a seems to be using Arc<T> for interning, going to open a convo on zulip https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/interning.20and.20requiring.20.60Copy.60

compiler/rustc_middle/src/ty/consts.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/context.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/mod.rs Show resolved Hide resolved
compiler/rustc_middle/src/ty/mod.rs Show resolved Hide resolved
compiler/rustc_next_trait_solver/src/canonicalizer.rs Outdated Show resolved Hide resolved
compiler/rustc_next_trait_solver/src/canonicalizer.rs Outdated Show resolved Hide resolved
compiler/rustc_next_trait_solver/src/canonicalizer.rs Outdated Show resolved Hide resolved
compiler/rustc_next_trait_solver/src/canonicalizer.rs Outdated Show resolved Hide resolved
compiler/rustc_type_ir/src/canonical.rs Outdated Show resolved Hide resolved
compiler/rustc_type_ir/src/infcx.rs Show resolved Hide resolved
@lcnr
Copy link
Contributor

lcnr commented Dec 1, 2023

After talking about this on zulip, I think we should go with requiring Copy for now, switching to Clone if necessary.

@compiler-errors
Copy link
Member Author

The only feedback I did not integrate was the:

trait InferCtxtLike {
  type Interner: Interner<Ty = Self::Ty>;
  type Ty: Bound + Bound + Bound + ...;

Because:

  1. It's not possible to uplift Binder<T> like this because it would require expressing a for<T> bound, and
  2. It's not that much better imo.

@rustbot ready

Copy link
Contributor

@lcnr lcnr 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 after nit

compiler/rustc_middle/src/ty/context.rs Show resolved Hide resolved
compiler/rustc_next_trait_solver/src/canonicalizer.rs Outdated Show resolved Hide resolved
@compiler-errors
Copy link
Member Author

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Dec 7, 2023

📌 Commit 1c1df45 has been approved by lcnr

It is now in the queue for this repository.

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 7, 2023
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Dec 7, 2023
compiler-errors added a commit to compiler-errors/rust that referenced this pull request Dec 7, 2023
… r=lcnr

Uplift the (new solver) canonicalizer into `rustc_next_trait_solver`

Uplifts the new trait solver's canonicalizer into a new crate called `rustc_next_trait_solver`.

The crate name is literally a bikeshed-avoidance name, so let's not block this PR on that -- renames are welcome later.

There are a host of other changes that were required to make this possible:
* Expose a `ConstTy` trait to get the `Interner::Ty` from a `Interner::Const`.
* Expose some constructor methods to construct `Bound` variants. These are currently methods defined on the interner themselves, but they could be pulled into traits later.
* Expose a `IntoKind` trait to turn a `Ty`/`Const`/`Region` into their corresponding `*Kind`s.
* Some minor tweaks to other APIs in `rustc_type_ir`.

The canonicalizer code itself is best reviewed **with whitespace ignored.**

r? `@lcnr`
@bors
Copy link
Contributor

bors commented Dec 7, 2023

☔ The latest upstream changes (presumably #118324) 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 Dec 7, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 7, 2023
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#116420 (discard invalid spans in external blocks)
 - rust-lang#118686 (Only check principal trait ref for object safety)
 - rust-lang#118688 (Add method to get type of an Rvalue in StableMIR)
 - rust-lang#118707 (Ping GuillaumeGomez for changes in rustc_codegen_gcc)
 - rust-lang#118712 (targets: remove not-added {i386,i486}-unknown-linux-gnu)
 - rust-lang#118719 (CFI: Add char to CFI integer normalization)

Failed merges:

 - rust-lang#117586 (Uplift the (new solver) canonicalizer into `rustc_next_trait_solver`)

r? `@ghost`
`@rustbot` modify labels: rollup
- Take more things by self, not &self
- Clone more things
- Rework namespacing so we can use `ty::` in the canonicalizer
@compiler-errors
Copy link
Member Author

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Dec 8, 2023

📌 Commit 80f240a has been approved by lcnr

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 8, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 8, 2023
… r=lcnr

Uplift the (new solver) canonicalizer into `rustc_next_trait_solver`

Uplifts the new trait solver's canonicalizer into a new crate called `rustc_next_trait_solver`.

The crate name is literally a bikeshed-avoidance name, so let's not block this PR on that -- renames are welcome later.

There are a host of other changes that were required to make this possible:
* Expose a `ConstTy` trait to get the `Interner::Ty` from a `Interner::Const`.
* Expose some constructor methods to construct `Bound` variants. These are currently methods defined on the interner themselves, but they could be pulled into traits later.
* Expose a `IntoKind` trait to turn a `Ty`/`Const`/`Region` into their corresponding `*Kind`s.
* Some minor tweaks to other APIs in `rustc_type_ir`.

The canonicalizer code itself is best reviewed **with whitespace ignored.**

r? `@lcnr`
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 8, 2023
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#117586 (Uplift the (new solver) canonicalizer into `rustc_next_trait_solver`)
 - rust-lang#118692 (remove redundant imports)
 - rust-lang#118694 (Add instance evaluation and methods to read an allocation in StableMIR)
 - rust-lang#118715 (privacy: visit trait def id of projections)
 - rust-lang#118730 (recurse into refs when comparing tys for diagnostics)
 - rust-lang#118736 (temporarily revert "ice on ambguity in mir typeck")

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 9, 2023
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#117586 (Uplift the (new solver) canonicalizer into `rustc_next_trait_solver`)
 - rust-lang#118502 (fix: correct the arg for 'suggest to use associated function syntax' diagnostic)
 - rust-lang#118694 (Add instance evaluation and methods to read an allocation in StableMIR)
 - rust-lang#118715 (privacy: visit trait def id of projections)
 - rust-lang#118730 (recurse into refs when comparing tys for diagnostics)
 - rust-lang#118736 (temporarily revert "ice on ambguity in mir typeck")

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 4df6134 into rust-lang:master Dec 9, 2023
11 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Dec 9, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 9, 2023
Rollup merge of rust-lang#117586 - compiler-errors:the-canonicalizer, r=lcnr

Uplift the (new solver) canonicalizer into `rustc_next_trait_solver`

Uplifts the new trait solver's canonicalizer into a new crate called `rustc_next_trait_solver`.

The crate name is literally a bikeshed-avoidance name, so let's not block this PR on that -- renames are welcome later.

There are a host of other changes that were required to make this possible:
* Expose a `ConstTy` trait to get the `Interner::Ty` from a `Interner::Const`.
* Expose some constructor methods to construct `Bound` variants. These are currently methods defined on the interner themselves, but they could be pulled into traits later.
* Expose a `IntoKind` trait to turn a `Ty`/`Const`/`Region` into their corresponding `*Kind`s.
* Some minor tweaks to other APIs in `rustc_type_ir`.

The canonicalizer code itself is best reviewed **with whitespace ignored.**

r? ``@lcnr``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants