rust
Otherrust-lang/rust
Main repository for the Rust language: compiler, standard library and docs.
Overview
The official source repository of the Rust programming language, containing the rustc compiler, standard library, and documentation. Rust focuses on performance, memory safety without a garbage collector, and fearless concurrency. It ships with a rich toolchain including the Cargo package manager, rustfmt formatter and Clippy linter.
README Preview
\n \n \n \n \n \n\n[Website][Rust] | [Getting started] | [Learn] | [Documentation] | [Contributing]\n\n\nThis is the main source code repository for [Rust]. It contains the compiler,\nstandard library, and documentation.\n\n[Rust]: https://www.rust-lang.org/\n[Getting Started]: https://www.rust-lang.org/learn/get-started\n[Learn]: https://www.rust-lang.org/learn\n[Documentation]: https://www.rust-lang.org/learn#learn-use\n[Contributing]: CONTRIBUTING.md\n\n## Why Rust?\n\n- **Performance:** Fast and memory-efficient, suitable for critical services, embedded devices, and easily integrated with other languages.\n\n- **Reliability:** Our rich type system and ownership model ensure memory and thread safety, reducing bugs at compile-time.\n\n- **Productivity:** Comprehensive documentation, a compiler committed to providing great diagnostics, and advanced tooling including package manager and build tool ([Cargo]), auto-formatter ([rustfmt]), linter ([Clippy]) and editor support ([rust-analyzer]).\n\n[Cargo]: https://github.com/rust-lang/cargo\n[rustfmt]: https://github.com/rust-lang/rustfmt\n[Clippy]: https://github.com/rust-lang/rust-clippy\n[rust-analyzer]: https://github.com/rust-lang/rust-analyzer\n\n## Quick Start\n\nRead ["Installation"] from [The Book].\n\n["Installation"]: https://doc.rust-lang.org/book/ch01-01-installation.html\n[The Book]: https://doc.rust-lang.org/book/index.html\n\n## Installing from Source\n\nIf you really want to install from source (though this is not recommended), see\n[INSTALL.md](INSTALL.md).\n\n## Getting Help\n\nSee https://www.rust-lang.org/community for a list of chat platforms and forums.\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\n\nFor a detailed explanation of the compiler's architecture and how to begin contributing, see the [rustc-dev-guide](https://rustc-dev-guide.rust-lang.org/).\n\n## License\n\nRust is primarily distributed under the terms of both the MIT license and the\nApache License (Versio
FAQ (5)
TroubleshootingHow to fix Rust error 'internal compiler error: encountered incremental compilation error with evaluate_obligation'?
This is an incremental compilation cache corruption ICE, not a bug in your code. Fix it by clearing the incremental cache:
1. Run cargo clean -p <crate_name> (e.g. cargo clean -p jmap) to clear only the affected crate, or run full cargo clean to wipe all build artifacts.
2. Recompile with cargo build.
If the error keeps recurring, disable incremental compilation entirely by setting the environment variable CARGO_INCREMENTAL=0 or adding [build] incremental = false to .cargo/config.toml.
Since this is a compiler bug, you should also report it at https://github.com/rust-lang/rust/issues with a minimal reproduction (ideally the code before plus the patch that triggers the ICE on rebuild), including your rustc --version output and the fingerprint hash from the error.
TroubleshootingWhy does my Rust program crash with SIGFPE (division by zero) at opt-level 1+ when using checked_div().unwrap_unchecked(), and how to work around it?
This is a known rustc/LLVM miscompilation bug (rust-lang/rust #164431, affecting versions from ~1.87 through at least nightly 1.101). The optimizer lowers checked_div(...).unwrap_unchecked() into a bare div instruction that can receive a zero divisor after cross-function inlining, producing SIGFPE (exit code 136) at -C opt-level=1 and above, while -C opt-level=0 and Miri run clean. Workarounds until the bug is fixed: 1) Replace checked_div(...).unwrap_unchecked() with wrapping_div(...) — the crash disappears. 2) Add #[inline(never)] to the function being inlined into the caller — this blocks the cross-function inlining that triggers the bug. 3) Compile with -C opt-level=0 as a last resort. Note the bug is also address-layout sensitive: it reproduces with the default PIE build but not reliably with a non-PIE build.
TroubleshootingHow to fix 'cannot find type c_char in this scope' error when compiling libc crate on riscv64?
This E0425 error occurs because outdated libc versions (e.g., 0.2.43) lack riscv64 target definitions for core C types like c_char. Fix by upgrading libc to 0.2.190 or later. If libc is pinned by a dependency's Cargo.lock (such as the xsv crate used in cargotest), run cargo update -p libc inside the affected crate's directory, or manually bump the libc version in Cargo.lock/Cargo.toml, then rebuild. Do not follow the compiler's suggestion to import std::ffi::c_char — the missing definitions are a version issue, not an import issue.
TroubleshootingHow to fix Rust ICE "item_bounds called on DefId" when using inherent_associated_types?
This internal compiler error affects rustc 1.98.0-nightly (485ec3fbc 2026-06-10) when compiling recursive inherent associated types (e.g., type Assoc = &'a Foo<'a>::Assoc;) with flags -Znext-solver=globally -Zassumptions-on-binders. The fix: update to nightly 1.99.0 (ba28ff76f 2026-08-13) or newer via rustup update nightly, where the issue no longer reproduces. Note that inherent_associated_types is an incomplete, unstable feature known to cause compiler crashes — avoid it on stable/beta. Also, the triggering code is itself invalid (self-referential associated type produces E0271 type mismatch), so rewriting the associated type to not reference itself resolves it on affected versions.
TroubleshootingHow to fix 'type annotations needed' error after upgrading to Rust 1.99 beta?
This is a known type inference regression in Rust 1.99 beta (bisected to PR #158447, duplicate of issue #161913), affecting code where a closure passed to a generic constructor (e.g., Foo::new(&1u8, |input| *input)) could previously infer types. Fix: upgrade to Rust 1.100.0-beta.7 or later, where the regression no longer reproduces — run rustup update or switch channels with rustup default stable. Workaround if you must stay on 1.99 beta: add explicit type annotations to the closure parameter or generic arguments, e.g., |input: &u8| *input, or specify the full type on the binding such as let x: Foo<&u8, u8> = ....