We rely on rustfmt to automatically format our code.
We organize/separate imports into three blocks (all separated by one newline):
- 1st block for core language things:
- 2nd block for libraries:
- 3rd block for internal imports:
- 4th block for re-exports:
- 5th block for modules:
.rs file should (roughly) have the following structure:
Avoid the use of
pub in the kernel. Use
pub(super) etc. This
helps with dead code elimination.
We use AT&T syntax for assembly code (
options(att_syntax) in Rust
Libraries and binaries only have non-additive / non-conflicting feature flags.
This helps to spot compilation problems quickly (e.g. with
cargo build --all-features)
KError type is used to represent errors in the kernel. Whenever possible,
each variant should only be used once/in a single location (to be easy to grep
for) and should have a descriptive name.
We follow the conventions on How to Write a Git Commit Message.
Be sure to include any related GitHub issue references in the commit message. See GFM syntax for referencing issues and commits.
Since github doesn't do fast-forward merges through the UI, after PR passes test, merge it on the command line to keep the same commit hashes of the branch in master:
git checkout master git merge --ff-only feature-branch-name