-
Notifications
You must be signed in to change notification settings - Fork 183
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
Cleanup crate structure and add features for SLG/recursive solvers #459
Cleanup crate structure and add features for SLG/recursive solvers #459
Conversation
chalk-engine = { version = "0.10.1-dev", path = "../chalk-engine", optional = true } | ||
chalk-ir = { version = "0.10.1-dev", path = "../chalk-ir", default-features = false } | ||
|
||
[dev-dependencies] | ||
chalk-integration = { version = "0.10.1-dev", path = "../chalk-integration" } | ||
|
||
[features] | ||
default = ["slg-solver", "recursive-solver"] | ||
|
||
slg-solver = ["chalk-engine", "chalk-ir/slg-solver"] | ||
recursive-solver = [] |
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.
I ran into rust-lang/cargo#7916 while testing the feature flags, but I don't think it affects downstream users (like RA). The issue is that a cargo check --no-default-features --features recursive-solver
in chalk-solve
would still compile chalk-engine
because the dev-dependency chalk-integration
implicitly enables chalk-ir
's slg-solver
feature. If the dev-dependency features are not unified, this issue goes away (tested on nightly with -Z features=dev_dep
).
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.
Hmm. So what are the implications of this? We just always have to compile with both features?
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.
I think it works as expected for downstream crates (with recursive-solver
, chalk-engine
is not compiled and vice versa). However, when running commands in this repo like cargo test
/cargo check
, both solvers will get built.
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.
Yup, had some experience with it. This is okay.
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.
Can you update the book's coverage of the chalk crates to reflect the changes?
I think I'd also like to see a directed graph (in a hackmd or in a book) that shows all the crates we intend to wind up with and summarizes their purpose. I think it'd be helpful.
I'm starting to lean mildly towards "let's have fewer crates" versus a bunch of really narrow ones, but haven't made up my mind on that point.
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.
This definitely makes me wonder if it's just worth moving chalk-engine
code into chalk-solve
. In a separate module, like recursive
. I'm not entirely sure how I feel about this. Since they API boundary between the chalk-engine
and chalk-solve
seemed helpful for me when I was first getting into it. But I think maybe just it being in a separate module would be enough. And it means that the idea that the engine is a "standalone prolog solver" kind of goes away.
chalk-engine-base/Cargo.toml
Outdated
@@ -1,7 +1,7 @@ | |||
[package] | |||
name = "chalk-macros" | |||
name = "chalk-engine-base" |
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.
I don't particularly like the name chalk-engine-base
. Maybe just chalk-base
?
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.
Or, since chalk-ir
is getting a feature flag. Just have this be part of chalk-engine
with all SLG stuff under a feature flag.
Not sure how I feel about this one.
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.
If it's part of chalk-engine
, 90% of the crate will be under one feature flag.
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.
Yeah, exactly. Which is probably not a great tradeoff to just get rid of a small crate.
chalk-engine = { version = "0.10.1-dev", path = "../chalk-engine", optional = true } | ||
chalk-ir = { version = "0.10.1-dev", path = "../chalk-ir", default-features = false } | ||
|
||
[dev-dependencies] | ||
chalk-integration = { version = "0.10.1-dev", path = "../chalk-integration" } | ||
|
||
[features] | ||
default = ["slg-solver", "recursive-solver"] | ||
|
||
slg-solver = ["chalk-engine", "chalk-ir/slg-solver"] | ||
recursive-solver = [] |
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.
Hmm. So what are the implications of this? We just always have to compile with both features?
So -- I tend to think that the engine boundary is useful conceptually, but what I don't think is all that useful is the fact that the engine is totally generic over all the types. I feel like one of the following two options makes sense:
If we did the latter, there would still need to be a kind of "context" trait, but it would be much thinner, I imagine? Conceptually, we could go further, and move the unification code and some other things from chalk-solve into chalk-ir as well, which would probably narrow the interface further. However, I might not want to do that, or at least I might want to wait until the sem-vs-syn split proceeds a bit, because I think I'd like it if the "semantic unification" remained in chalk-solve, as it is kind of "Rust-specific semantics" and feels like a better fit for a callback. |
I think either of your ideas - moving chalk-engine into chalk-solve, or making chalk-engine depend on chalk-ir - would be good.
I think this would be the same trait that we would get by having it in a separate crate Moving unification and such code into chalk-ir I'm less inclined to do. I think we should strive to make chalk-ir as "type library"-like as possible, and less "trait solver library"-like. I guess unification can fall under types, but I'm not sure. I'm more or less thinking long-term in regards to rustc integration, what we might want things to look like. Specifically, right now chalk-ir is a dependency in rustc_middle. Later on, the shared type library will probably also be a dependency of rustc_middle. |
I'm not sure if I have the context to do this, but maybe it wasn't directed at me :) |
The book lint check is failing because the new |
Yes -- and ideally it'd be the same trait for both solvers, too.
I'm happy to wait, though I was thinking of the same thing (that is, currently rustc has its unification code in |
@Mcat12 how much do you want to try to experiment here? Would you like to try to turn this into a bit of a refactor to make chalk-engine depend on chalk-ir? |
I'm ok with experimenting but I'm afraid it might make this PR too large (there are other nice changes in this PR like moving |
I think the changes here are fine. @nikomatsakis do we want to merge this? Or wait for docs? Or wait for refactor? |
I think the docs are done, please feel free to point out if they are not completely updated. |
I'm referring to Niko's suggestion of adding the directed graph |
I think we can wait on the directed graph until we know what we want |
I would be happy to edit in a hackmd to start |
Enabling one but not the other avoids compiling an unnecessary solver.
Closes #456
chalk-rust-ir
crate is moved intochalk-solve
as therust_ir
module.chalk-macros
is renamed tochalk-base
and some types are moved there fromchalk-engine
so that the recursive solver does not depend onchalk-engine
.chalk-solve
so that only one solver needs to be compiled. By default, both features are enabled.