Skip to content

Conversation

@ShoyuVanilla
Copy link
Member

r? lcnr

@rustbot rustbot added the S-waiting-on-review Status: this PR is waiting for a reviewer to verify its content label Dec 2, 2025
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.

Thanks for writing this 😊

I think we should explain a few specific concepts here and would have separate headers for each of them:

  • trait Interner already mostly done
    • I'd explicitly mention that it corresponds to the TyCtxt in rustc and is where we put rustc querys
  • mod inherent
    • forward definitions of inherent methods on compiler specific types
    • should be imported via use inherent::*; in the generic crates
    • never used inside of the implementations themselves, they should use the inherent methods of the actual types once they are nameable
  • trait InferCtxtLike and trait SolverDelegate
    • corresponds to the InferCtxt in rustc
    • InferCtxtLike has do be defined in rustc_infer due to coherence rules, does not provide functionality defined in rustc_trait_selection
    • that behavior is abstracted over via the separate SolverDelegate trait
    • ideally all of SolverDelegate should be extracted into the rustc_next_trait_solver with the necessary core operations added to InferCtxtLike
  • rustc_type_ir::search_graph::{Cx, Delegate}
    • abstraction traits already implemented in rustc_next_trait_solver itself, used to support fuzzing of the search graph outside of the trait solver in https://github.com/lcnr/search_graph_fuzz, not relevant for users of the trait solver

`rustc_next_trait_solver`, which provide the core IR and solver logic used by both compiler
frontends.

## The Abstract Layer
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
## The Abstract Layer
## The Abstraction Layer

I think? The layer is used to abstract something, it's not abstract itself

This requires an infrastructure quite different from rustc's, especially in the layers between
the source code and the HIR—for example, `Ty` and its backing interner.

To bridge these differences, the compiler provides `rustc_type_ir` as an abstract layer shared
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
To bridge these differences, the compiler provides `rustc_type_ir` as an abstract layer shared
To bridge these differences, the compiler provides `rustc_type_ir` as an abstraction layer shared

Comment on lines +61 to +63
To support this, the type-system traits in `rustc_type_ir` must expose every interface the solver
requires—for example, [creating a new inference type variable][ir new_infer]
([rustc][rustc new_infer], [rust-analyzer][r-a new_infer])
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
To support this, the type-system traits in `rustc_type_ir` must expose every interface the solver
requires—for example, [creating a new inference type variable][ir new_infer]
([rustc][rustc new_infer], [rust-analyzer][r-a new_infer])
To support this, the type-system traits in `rustc_type_ir` must expose every interface the solver
requires—for example, [creating a new inference type variable][ir new_infer]
([rustc][rustc new_infer], [rust-analyzer][r-a new_infer]).

@ShoyuVanilla
Copy link
Member Author

Thanks for the review! I'll apply your feedback some hours later 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: this PR is waiting for a reviewer to verify its content

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants