๐Ÿ“ฆ rust-lang / chalk

An implementation and definition of the Rust trait system using a PROLOG-like logic solver

โ˜… 2.0k stars โ‘‚ 181 forks ๐Ÿ‘ 2.0k watching โš–๏ธ Other
๐Ÿ“ฅ Clone https://github.com/rust-lang/chalk.git
HTTPS git clone https://github.com/rust-lang/chalk.git
SSH git clone git@github.com:rust-lang/chalk.git
CLI gh repo clone rust-lang/chalk
Github Action Github Action Release 0.105.0-dev.0 94db658 5 months ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ .github
๐Ÿ“ book
๐Ÿ“ chalk-derive
๐Ÿ“ chalk-engine
๐Ÿ“ chalk-integration
๐Ÿ“ chalk-ir
๐Ÿ“ chalk-parse
๐Ÿ“ chalk-recursive
๐Ÿ“ chalk-solve
๐Ÿ“ src
๐Ÿ“ tests
๐Ÿ“„ .dir-locals.el
๐Ÿ“„ .gitignore
๐Ÿ“„ Cargo.lock
๐Ÿ“„ Cargo.toml
๐Ÿ“„ CONTRIBUTING.md
๐Ÿ“„ COPYRIGHT
๐Ÿ“„ GLOSSARY.md
๐Ÿ“„ libstd.chalk
๐Ÿ“„ LICENSE-APACHE
๐Ÿ“„ LICENSE-MIT
๐Ÿ“„ README.md
๐Ÿ“„ RELEASES.md
๐Ÿ“„ triagebot.toml
๐Ÿ“„ README.md

Build Status Chalk Book Rust Documentation

chalk

Chalk is a library that implements the Rust trait system, based on Prolog-ish logic rules.

See the Chalk book for more information.

FAQ

How does chalk relate to rustc? The plan is to have rustc use the chalk-solve crate (in this repo) to answer questions about Rust programs, for example, "Does Vec<u32> implement Debug?". Internally, chalk converts Rust-specific information into logic and uses a logic engine to find the answer to the original query. For more details, see this explanation in the chalk book.

Where does the name come from? chalk is named after [Chalkidiki], the area where [Aristotle] was born. Since Prolog is a logic programming language, this seemed a suitable reference.

Blog posts

Here are some blog posts talking about chalk:

  • Handling cyclic relations and enabling the implementation of implied bounds and other long-desired features in an elegant way

REPL

There is a repl mainly for debugging purposes which can be run by cargo run. Some basic examples are in libstd.chalk:

$ cargo run
?- load libstd.chalk
?- Vec<Box<i32>>: Clone
Unique; substitution [], lifetime constraints []

Contributing

If you'd like to contribute, consider joining the Traits Working Group. We hang out on the rust-lang zulip in the #wg-traits stream.

See the contributing chapter in the chalk book for more info.