Skip to content

Rename InferCtxtLike to SolverDelegate, use a newtype to define an impl in rustc_next_trait_solver#126498

Closed
compiler-errors wants to merge 3 commits intorust-lang:masterfrom
compiler-errors:delegate
Closed

Rename InferCtxtLike to SolverDelegate, use a newtype to define an impl in rustc_next_trait_solver#126498
compiler-errors wants to merge 3 commits intorust-lang:masterfrom
compiler-errors:delegate

Conversation

@compiler-errors
Copy link
Copy Markdown
Contributor

This is so we can add things like vtable walking methods to the SolverDelegate trait without needing to worry about how things are defined in rustc_trait_solver and not rustc_infer.

  1. Move InferCtxtLike to rustc_next_trait_solver and rename it to SolverDelegate.
  2. Add a newtype struct RustcSolverDelegate<'tcx>(InferCtxt<'tcx>) and use repr(transparent) to unsafely interconvert between them.

This is based on #126496 -- I split those relatively mechanical commits out in case we want to bikeshed on design here, since I'm not totally certain this is the best tradeoff of approach.

r? lcnr

@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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jun 14, 2024
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 14, 2024

Some changes occurred to the core trait solver

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

@compiler-errors
Copy link
Copy Markdown
Contributor Author

compiler-errors commented Jun 14, 2024

This might be overkill. I could perhaps alternatively uplift the vtable walking code into rustc_next_trait_solver, and keep InferCtxtLike as is. AFAICT there's no other places in the new solver that rely on code that's implemented in rustc_trait_selection not rustc_infer, but I'm not certain if it'll stay that way.

edit: Actually, specialization_graph machinery is defined in rustc_trait_solver. However, we could also emulate that by just exposing the Ancestors iterator.

@compiler-errors
Copy link
Copy Markdown
Contributor Author

Actually, yeah? I think this is overkill lol. If the only reason we need to do this is because of walk_vtable, then I'd rather find a better solution for that.

@compiler-errors
Copy link
Copy Markdown
Contributor Author

the better solution: #126505

@compiler-errors compiler-errors deleted the delegate branch June 15, 2024 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants