RS.CLIPPY.EXCESSIVE_NESTING
Checks for blocks nested beyond a certain threshold
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: excessive_nesting. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for blocks which are nested beyond a certain threshold.
Note: Even though this lint is warn-by-default, it will only trigger if a maximum nesting level is defined in the clippy.toml file.
Why is this bad?
It can severely hinder readability.
Example
An example clippy.toml configuration:
excessive-nesting-threshold = 3
// lib.rs
pub mod a {
pub struct X;
impl X {
pub fn run(&self) {
if true {
// etc...
}
}
}
}
Use instead:
// a.rs
fn private_run(x: &X) {
if true {
// etc...
}
}
pub struct X;
impl X {
pub fn run(&self) {
private_run(self);
}
}
// lib.rs
pub mod a;
Configuration
-
excessive-nesting-threshold: The maximum amount of nesting a block can reside in(default:
0)