BorrowCheck › Rust language core
Modules, Cargo, features, editions
Module tree, visibility, crates and workspaces, features and cfg, editions and MSRV, SemVer.
The topic explains how code is organized beyond a single file: the crate's module tree, Cargo packages and workspaces, features, editions and versioning. The questions on the module tree check where a module body lives, why a child module does not inherit use, how conflicts between explicit and glob imports are resolved, and how one name lives in different namespaces. The subtopic on visibility covers pub(crate), pub(super) and pub(in …), a child's access to the private items of its ancestors, private fields in a struct literal, and a private type in a public signature. A separate part covers packages and workspaces: how many crates a package may hold, the crate name versus the package name, a virtual manifest, inherited dependencies, and settings that take effect only in the workspace root. The subtopic on features explains #[cfg], cfg! and cfg_attr, features created by optional dependencies, the additivity of features, and the behavior of resolver version 2. The last subtopics are about editions and the rust-version field, the changes of edition 2024, SemVer requirements in Cargo, and the role of Cargo.lock.
41 questions: 17 basic, 19 intermediate, 5 advanced. 6 info pages, 37 sources.
Subtopics
- Module tree and
use - Visibility:
pub,pub(crate) - Crates and workspaces
- Features and conditional compilation
- Editions and MSRV
- SemVer and
Cargo.lock
Previous: Error handling · Next: Smart pointers, interior mutability