-
Notifications
You must be signed in to change notification settings - Fork 563
Mention sharing the solver with rust-analyzer #2668
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
base: main
Are you sure you want to change the base?
Conversation
lcnr
left a comment
There was a problem hiding this 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 Interneralready mostly done- I'd explicitly mention that it corresponds to the
TyCtxtinrustcand is where we put rustc querys
- I'd explicitly mention that it corresponds to the
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 InferCtxtLikeandtrait SolverDelegate- corresponds to the
InferCtxtin rustc InferCtxtLikehas do be defined inrustc_inferdue to coherence rules, does not provide functionality defined inrustc_trait_selection- that behavior is abstracted over via the separate
SolverDelegatetrait - ideally all of
SolverDelegateshould be extracted into therustc_next_trait_solverwith the necessary core operations added toInferCtxtLike
- corresponds to the
rustc_type_ir::search_graph::{Cx, Delegate}- abstraction traits already implemented in
rustc_next_trait_solveritself, 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
- abstraction traits already implemented in
| `rustc_next_trait_solver`, which provide the core IR and solver logic used by both compiler | ||
| frontends. | ||
|
|
||
| ## The Abstract Layer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ## 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 |
| 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]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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]). |
|
Thanks for the review! I'll apply your feedback some hours later 😄 |
r? lcnr