Chalk: Rust Trait Logic Explained
An implementation and definition of the Rust trait system using a PROLOG-like logic solver
At a glance
- What is it?
- Chalk models Rust trait queries through Prolog-like logical inference, but its README says the project has been sunset in favor of Rust's newer trait solver. It remains useful for studying and experimenting with trait-system reasoning rather than serving as the new compiler solver.
- Who is it for?
- Chalk fits compiler researchers, Rust contributors, and developers who want to study trait-system inference through a real Rust implementation. It is a poor fit for a new compiler integration that expects long-term alignment with rustc.
- Can I use it commercially?
- Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
- Is it still maintained?
- Yes. The repository last received commits 26 days ago.
- What is it written in?
- Mainly Rust, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 7, 2026, and from our analysis. They are not legal advice.
Star history
- rust-lang/chalk2,023 ★ · +3
| Repository | 2026-10-18 | 2026-11-07 |
|---|---|---|
| rust-lang/chalk | 2k | 2k |
3 Stars in the last 20 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
Chalk's Rust trait-solving purpose
Chalk addresses a precise compiler problem: deciding Rust trait questions through explicit logical rules. The README gives the example of whether `Vec<u32>` implements `Debug`. Its intended audience is Rust compiler work and trait-system experimentation, rather than application developers looking for a general dependency resolver or reflection library.
The implementation treats Rust concepts as a Prolog-like language. That design makes the relationship between implementations, obligations, substitutions, and lifetimes inspectable as logic. The README also describes Chalk as both an implementation and a model of the Rust trait system. It is therefore useful in two settings: as Rust code that can answer modeled trait queries, and as a reference for how a logic-based solver can represent compiler semantics.
There is an important adoption boundary. The repository warning says that Chalk has been "sunset" in favor of the newer next-generation trait solver. That statement outweighs the fact that the repository is not archived and that its last push was on 2026-10-12. Recent repository activity does not turn Chalk into the future replacement for rustc's solver. The intended relationship described in the README is historical: the plan was for rustc to use the `chalk-solve` crate to answer questions about Rust programs, but the warning directs users toward newer Rust trait-system work.
From Rust queries to logical inference
According to the README, Chalk first converts Rust-specific information into logic, then passes the resulting query to a logic engine. The solver attempts to derive an answer to the original trait question. This is the central distinction from looking up an implementation through a conventional runtime trait table. Chalk represents the obligation and reasons that may satisfy it as inference rules.
The repository layout exposes several stages of that design. `chalk-ir` contains the intermediate representation, `chalk-parse` handles parsing, and `chalk-solve` provides the solving layer. Supporting crates include `chalk-engine`, `chalk-recursive`, `chalk-integration`, and `chalk-derive`. The root `chalk` package depends on these local components, while the root `tests/` directory provides a visible place for test assets.
The README also links to technical explanations of lowering Rust traits into logic, unification, associated types, negative reasoning, and cyclic queries. Those subjects indicate the kinds of compiler questions this model is designed to represent. They do not, by themselves, establish that Chalk implements the complete current rustc trait system. The sunset notice makes that distinction especially important. Chalk is a model and experimental implementation, while the README positions rustc's newer trait solver as the forward path.
Running Chalk's debugging REPL
The README does not provide a separate installation procedure for an end user. The concrete first-use path is the debugging REPL, launched from the repository with `cargo run`. No package flag, server port, environment variable, or invented setup command is documented.
From the repository root, run:
cargo runThe README says this opens a REPL intended mainly for debugging. After the prompt appears, load the included example environment:
?- load libstd.chalkThen enter the trait query shown in the README:
?- Vec<Box<i32>>: CloneThe documented response is:
Unique; substitution [], lifetime constraints []This example is a genuine first query rather than a syntax-only demonstration. It asks whether the nested type `Vec<Box<i32>>` satisfies the `Clone` obligation in the loaded environment. The response reports a unique answer, no substitution, and no lifetime constraints. The README does not document installation for using Chalk as a dependency in another Rust project, nor does it provide a stable query API tutorial. For the confirmed workflow, the source checkout and its bundled `libstd.chalk` are the relevant starting point.
Recursive solving and the repository's Rust modules
Chalk is a Cargo workspace with separate crates for parsing, intermediate representation, solving, recursion, integration, and derived representations. The root package uses edition 2018 and combines those local crates under the `chalk` executable or library package. This decomposition makes the system more than a single solver loop: syntax and representations are separated from solver behavior and host integration.
The presence of both `chalk-engine` and `chalk-recursive` indicates that solver organization is a significant project concern. The linked article on cyclic queries specifically discusses tabling and cyclic relations. Chalk's trait goals can form recursive structures, so an implementation cannot assume every answer is found through a simple, acyclic lookup path. The exact internal control flow is not documented in the README, so it would be unsafe to claim which solver mode handles every query. The defensible point is that recursion and query structure have dedicated code and dedicated project discussion.
For a potential adopter, that architecture is a strength if the goal is to inspect or modify the modeled trait system. It also creates a cost. Integrating Chalk means understanding its Rust-specific IR, parser, solver crates, and answer model rather than dropping a small library into a service. The `src/` directory supports the REPL route, while `tests/` holds repository tests. Neither the README nor `Cargo.toml` documents a supported external embedding API, so the documented REPL remains the clearest entry point for initial evaluation.
Chalk's sunset status and upgrade cost
The repository is not archived, and the last push was on 2026-10-12. Nevertheless, the explicit sunset warning means new adoption must account for project direction. A recent commit can update documentation or code while the project still states that rustc's newer trait solver is the successor path.
The only listed recent release is `v0.10.0` from 2020-04-30. The root package currently identifies itself as `0.105.0-dev.0` and sets `publish = false`. These are separate signals. The package version is a development version, while the release history does not show a matching current public release. The README does not document a release plan or compatibility policy for downstream users, so upgrade expectations cannot be inferred from the package version alone.
License handling is unusually concrete. `Cargo.toml` declares `license = "MIT OR Apache-2.0"`, and the repository contains both `LICENSE-APACHE` and `LICENSE-MIT`. The repository metadata classifies the license as another custom license because GitHub cannot classify it, but the manifest and license files provide an inspectable record. This is a licensing point to verify against the exact files, not a legal conclusion. The upgrade burden also includes checking whether a future Rust trait-solver change invalidates assumptions in a Chalk-based prototype.
Why Chalk differs from rustc's current solver path
The real alternative identified by the repository is Rust's newer next-generation trait solver. The README's warning points to Rust project posts about the trait-system refactor initiative and later solver work. Chalk and that solver differ in role and direction: Chalk is an existing standalone library and model based on Prolog-like logic, while the newer solver is the path Rust development has chosen for its next-generation trait system.
This is more than a naming difference. Chalk's answer comes from lowering Rust information into logical inference and running a logic engine. A production compiler integration would also need to satisfy current rustc requirements, which the README does not claim Chalk will do. The README contains no compatibility table, benchmark, migration guide, or statement that the newer solver is source-compatible with Chalk.
For evaluation, the distinction determines the right question. Choose Chalk when the objective is to study or prototype logic-based trait reasoning, reproduce the README examples, or work within this repository's solver model. Do not choose it merely because the README once described a plan for rustc to use `chalk-solve`. The sunset notice removes that plan as a sound basis for a new production dependency.
Practical limits of Chalk's documented interface
The clearest limitation is interface scope. The README documents a debugging REPL and a small bundled example, but it does not document a stable command-line contract for production use, a public embedding example, configuration files, environment variables, or deployment guidance. The package's `publish = false` setting also means the root package is not configured for ordinary Cargo publication from the manifest.
The second limitation is semantic currency. Chalk is described as a model of the Rust trait system, but the README does not claim that this model covers every behavior of the current compiler. Its association with rustc is described as a plan, and the warning says the project has been sunset for newer solver work. Researchers can study the model, but they should not infer current rustc parity from the crate name or the original integration plan.
The third limitation is release and upgrade visibility. The release list contains one old public release, while the root manifest carries a development version. No release notes define migration steps for downstream code. This does not mean the repository is unusable. It means the evaluation should remain centered on the documented REPL and code organization unless a downstream use case can be supported by the project files.
Editorial conclusion
Chalk fits compiler researchers, Rust contributors, and developers who want to study trait-system inference through a real Rust implementation. It is a poor fit for a new compiler integration that expects long-term alignment with rustc. Before adopting it, check whether the downstream design can tolerate the sunset notice, the limited public release history, and the repository's custom-license classification, while using `MIT OR Apache-2.0` from `Cargo.toml` and the `LICENSE-APACHE` and `LICENSE-MIT` files as the concrete licensing record.
Frequently asked questions
What is Chalk in rust-lang/chalk?
It is a Rust library that models the Rust trait system with Prolog-like logical rules. The README says it converts Rust-specific information into logic and uses a logic engine to answer trait questions.
How do I run the Chalk REPL?
Run `cargo run` from the repository. The README then shows `load libstd.chalk` and the query `Vec<Box<i32>>: Clone`.
Is Chalk still the planned solver for rustc?
The README says the project has been sunset in favor of Rust's newer next-generation trait solver. It describes rustc use of `chalk-solve` as a plan, not as the current forward path.
Can I publish the root Chalk package as a normal dependency?
The `Cargo.toml` file sets `publish = false` for the root `chalk` package. It also uses the development version `0.105.0-dev.0`.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/rust-lang-chalk)Star history chart for your README
[](https://hysenlabs.com/projects/rust-lang-chalk)Was this useful?