How to Contribute to the Rust Compiler (rustc)

Start by finding a good first issue on the Rust triage repository, then follow the official contribution guide to set up your build environment and run the test suite.

Start by finding a good first issue on the Rust triage repository, then follow the official contribution guide to set up your build environment and run the test suite. You will need to clone the rust-lang/rust repository, configure your build with x.py, and submit a Pull Request that passes all CI checks.

First, clone the repository and set up your build. The Rust compiler is built using a custom Python-based build system called x.py. You don't need to install Rust via rustup to build the compiler itself, as the repository contains the necessary toolchain.

git clone https://github.com/rust-lang/rust.git
cd rust
# Initialize the submodules and build the compiler
./x.py build --stage 1

Once the build succeeds, you can run the test suite to ensure your environment is working correctly. Before making changes, always run the tests to establish a baseline.

# Run the full test suite (takes a while)
./x.py test

# Run tests for a specific component, e.g., the parser
./x.py test src/test/ui/parser

When you are ready to contribute, look for issues tagged with E-easy or E-mentor on the rust-lang/rust GitHub repository or the rust-lang/compiler team's triage board. These are curated for new contributors. Once you have identified an issue, fork the repository, create a branch, and make your changes.

git checkout -b fix-issue-12345
# Make your changes to src/librustc/...
./x.py test --stage 1 src/test/ui/your-test-case.rs
git commit -m "Fix issue #12345: describe the fix briefly"

Before pushing, ensure your code adheres to the project's formatting and linting standards. The x.py tool handles this automatically.

./x.py fmt
./x.py clippy --stage 1

Finally, push your branch to your fork and open a Pull Request against the main rust-lang/rust repository. The CI system will run extensive tests on your changes. Be prepared for code reviews; the Rust compiler team is thorough but helpful. If the CI fails, fix the errors locally and push again; the PR will update automatically. Remember to add a @rustbot label if you need specific attention, such as @rustbot label +T-compiler.