Cargo.toml lints
These [workspace.lints] tables turn on every rustc, rustdoc and clippy lint the kit uses. Paste them into your workspace root Cargo.toml and add [lints] workspace = true to each member crate. A single crate uses the same tables without workspace.; download crate-lints.toml for that version.
Download workspace-lints.toml · Download crate-lints.toml
# Google Rust Style Guide lints (unofficial kit): https://daniakash.github.io/Google-Rust-Style-Guide/# Paste into your workspace root Cargo.toml, then add `[lints] workspace = true` to each member.
[workspace.lints.rust]# https://google.github.io/styleguide/rustguide.html#when-and-how-to-write-documentationmissing_docs = "warn"# https://google.github.io/styleguide/rustguide.html#unsafe-codeunsafe_op_in_unsafe_fn = "warn"# https://google.github.io/styleguide/rustguide.html#no-unstable-featuresunstable_features = "deny"
[workspace.lints.rustdoc]# https://google.github.io/styleguide/rustguide.html#when-and-how-to-write-documentationbroken_intra_doc_links = "warn"
[workspace.lints.clippy]# Clippy's default groups (correctness, suspicious, style, complexity, perf) stay on.# Pedantic, restriction and nursery lints are opted into one at a time below.all = { level = "warn", priority = -1 }
# ---- Code organization ----# https://google.github.io/styleguide/rustguide.html#dont-use-glob-importswildcard_imports = "warn"# https://google.github.io/styleguide/rustguide.html#qualify-calls-to-top-level-functions-with-a-module-name and# https://google.github.io/styleguide/rustguide.html#type-names-should-be-imported-and-used-unqualifiedabsolute_paths = "warn"
# ---- Code formatting and aesthetics ----# https://google.github.io/styleguide/rustguide.html#use-the-appropriate-formatting-tool (escape invisible characters in literals)invisible_characters = "deny"
# ---- Ownership and borrowing ----# https://google.github.io/styleguide/rustguide.html#prefer-borrows-over-deep-copiesredundant_clone = "warn"implicit_clone = "warn"needless_pass_by_value = "warn"
# ---- Function inputs and outputs ----# https://google.github.io/styleguide/rustguide.html#accept-flexible-references-for-immutable-dataptr_arg = "warn"borrowed_box = "warn"ref_option = "warn"# https://google.github.io/styleguide/rustguide.html#prefer-enum-over-bool-in-apis (threshold in clippy.toml)fn_params_excessive_bools = "warn"struct_excessive_bools = "warn"
# ---- Traits ----# https://google.github.io/styleguide/rustguide.html#implement-known-standard-library-traits-instead-of-custom-methodsshould_implement_trait = "warn"inherent_to_string = "warn"from_over_into = "warn"# https://google.github.io/styleguide/rustguide.html#use-derive-if-possiblederivable_impls = "warn"expl_impl_clone_on_copy = "warn"# https://google.github.io/styleguide/rustguide.html#specific-guidance-for-important-traits (Default when there is a `new()`)new_without_default = "warn"
# ---- Naming ----# https://google.github.io/styleguide/rustguide.html#naming-methodswrong_self_convention = "warn"# https://google.github.io/styleguide/rustguide.html#naming-initialization-functionsnew_ret_no_self = "warn"
# ---- Documentation ----# https://google.github.io/styleguide/rustguide.html#when-and-how-to-write-documentationmissing_panics_doc = "warn"missing_errors_doc = "warn"missing_safety_doc = "warn"doc_markdown = "warn"
# ---- Other Rust features ----# https://google.github.io/styleguide/rustguide.html#unsafe-codeundocumented_unsafe_blocks = "warn"unnecessary_safety_comment = "warn"# https://google.github.io/styleguide/rustguide.html#implement-expected-api-sets-togetherlen_without_is_empty = "warn"# https://google.github.io/styleguide/rustguide.html#apply-non_exhaustive-to-publicly-exposed-enumsexhaustive_enums = "warn"# https://google.github.io/styleguide/rustguide.html#apply-non_exhaustive-to-public-structs-with-public-fieldsexhaustive_structs = "warn"# https://google.github.io/styleguide/rustguide.html#must_use-on-functionsmust_use_candidate = "warn"# https://google.github.io/styleguide/rustguide.html#avoid-rc-and-arc, #handling-poison, #dont-call-paniccatch_unwind (lists in clippy.toml)disallowed_types = "warn"disallowed_methods = "warn"
# ---- Implementation concerns ----# https://google.github.io/styleguide/rustguide.html#prefer-pattern-matching-over-check-then-unwrapunnecessary_unwrap = "warn"# https://google.github.io/styleguide/rustguide.html#prefer-expect-over-unwrapunwrap_used = "warn"# https://google.github.io/styleguide/rustguide.html#use-context-strings-to-clarify-assertionsmissing_assert_message = "warn"# https://google.github.io/styleguide/rustguide.html#dont-use-iterator-combinator-chains-when-direct-iteration-is-clearerneedless_for_each = "warn"# https://google.github.io/styleguide/rustguide.html#prefer-format--write-for-concatenation-and-substitutionformat_push_string = "warn"
# ---- Exceptions explain themselves ----# Every deviation from the guide is `#[expect(clippy::lint, reason = "...")]`.allow_attributes_without_reason = "warn"Source: Cargo.toml on GitHub. New to the kit? Start with the quick start.
Unofficial community project, not affiliated with or endorsed by Google. TheGoogle Rust Style Guide is published by Google under CC-BY 3.0. This kit is Apache-2.0.