@@ -19,6 +19,76 @@ at the root of the repository. You can find [more information about rustfmt
1919online] ( https://github.com/rust-lang/rustfmt ) too, such as how to configure
2020your editor.
2121
22+ ### Compiler Warnings and Lints
23+
24+ Wasmtime promotes all compiler warnings to errors in CI, meaning that the ` main `
25+ branch will never have compiler warnings for the version of Rust that's being
26+ tested on CI. Compiler warnings change over time, however, so it's not always
27+ guaranteed that Wasmtime will build with zero warnings given an arbitrary
28+ version of Rust. If you encounter compiler warnings on your version of Rust
29+ please feel free to send a PR fixing them.
30+
31+ During local development, however, compiler warnings are simply warnings and the
32+ build and tests can still succeed despite the presence of warnings. This can be
33+ useful because warnings are often quite prevalent in the middle of a
34+ refactoring, for example. By the time you make a PR, though, we'll require that
35+ all warnings are resolved or otherwise CI will fail and the PR cannot land.
36+
37+ Compiler lints are controlled through the ` [workspace.lints.rust] ` table in the
38+ ` Cargo.toml ` at the root of the Wasmtime repository. A few allow-by-default
39+ lints are enabled such as ` trivial_numeric_casts ` , and you're welcome to enable
40+ more lints as applicable. Lints can additionally be enabled on a per-crate basis
41+ such as placing this in a ` src/lib.rs ` file:
42+
43+ ``` rust
44+ #![warn(trivial_numeric_casts)]
45+ ```
46+
47+ Using ` warn ` here will allow local development to continue while still causing
48+ CI to promote this warning to an error.
49+
50+ ### Clippy
51+
52+ All PRs are gated on ` cargo clippy ` passing for all workspace crates and
53+ targets. All clippy lints, however, are allow-by-default and thus disabled. The
54+ Wasmtime project selectively enables Clippy lints on an opt-in basis. Lints can
55+ be controlled for the entire workspace via ` [workspace.lints.clippy] ` :
56+
57+ ``` toml
58+ [workspace .lints .clippy ]
59+ # ...
60+ manual_strip = ' warn'
61+ ```
62+
63+ or on a per-crate or module basis by using attributes:
64+
65+ ``` rust
66+ #![warn(clippy:: manual_strip)]
67+ ```
68+
69+ In Wasmtime we've found that the default set of Clippy lints is too noisy to
70+ productively use other Clippy lints, hence the allow-by-default behavior.
71+ Despite this though there are numerous useful Clippy lints which are desired for
72+ all crates or in some cases for a single crate or module. Wasmtime encourages
73+ contributors to enable Clippy lints they find useful through workspace or
74+ per-crate configuration.
75+
76+ Like compiler warnings in the above section all Clippy warnings are turned into
77+ errors in CI. This means that ` cargo clippy ` should always produce no warnings
78+ on Wasmtime's ` main ` branch if you're using the same compiler version that CI
79+ does (typically current stable Rust). This means, however, that if you enable a
80+ new Clippy lint for the workspace you'll be required to fix the lint for all
81+ crates in the workspace to land the PR in CI.
82+
83+ Clippy can be run locally with:
84+
85+ ``` shell
86+ $ cargo clippy --workspace --all-targets
87+ ```
88+
89+ Contributors are welcome to enable new lints and send PRs for this. Feel free to
90+ reach out if you're not sure about a lint as well.
91+
2292### Minimum Supported ` rustc ` Version
2393
2494Wasmtime and Cranelift support the latest three stable releases of Rust. This
0 commit comments