summary
cargo fix doesn't apply suggestions in a single pass — it re-runs the compiler and re-applies fixes in a loop, because fixing one warning can often expose another one underneath it. To keep this from running forever, it stops after 4 iterations by default.
That limit is actually configurable. There's an env var for it already sitting in the code:
let max_iterations = gctx
.get_env("CARGO_FIX_MAX_RETRIES")
.ok()
.and_then(|n| n.parse().ok())
.unwrap_or(4);
src/ops/cargo_fix/mod.rs, around line 914.
.But it's never been written down anywhere, not in environment-variables.md, If you didn't already know this variable exists, the only way to find out is to go read the source.
fix
add CARGO_FIX_MAX_RETRIES to the "Environment variables Cargo reads" section of environment-variables.md, describing what it does and that the default is 4. Might be worth a short mention in the cargo-fix docs as well, since that's probably where someone debugging this would look first.
summary
cargo fix doesn't apply suggestions in a single pass — it re-runs the compiler and re-applies fixes in a loop, because fixing one warning can often expose another one underneath it. To keep this from running forever, it stops after 4 iterations by default.
That limit is actually configurable. There's an env var for it already sitting in the code:
let max_iterations = gctx
.get_env("CARGO_FIX_MAX_RETRIES")
.ok()
.and_then(|n| n.parse().ok())
.unwrap_or(4);
src/ops/cargo_fix/mod.rs, around line 914.
.But it's never been written down anywhere, not in environment-variables.md, If you didn't already know this variable exists, the only way to find out is to go read the source.
fix
add CARGO_FIX_MAX_RETRIES to the "Environment variables Cargo reads" section of environment-variables.md, describing what it does and that the default is 4. Might be worth a short mention in the cargo-fix docs as well, since that's probably where someone debugging this would look first.