Cargo with less noise: - errors have highest priority - they never appear in the middle of warnings - warnings are skipped by default until errors are fixed - all dependencies' warnings are skipped by default - all messages come in reversed order by default - to avoid extra scrolling - duplicated messages are skipped - messages are grouped by filenames - number of messages can be limited - after encountering first error the rest of build time is limited by default
This tool is especially useful in combination with cargo-watch.
cargo install cargo-limit
cargo install --force --git https://github.com/alopatindev/cargo-limit
Run any of these in your project:
cargo lbench
cargo lbuild
cargo lcheck
cargo lclippy
cargo lfix
cargo lrun
cargo ltest
CARGO_MSG_LIMIT
0 means no limit, which is defaultCARGO_TIME_LIMIT
cargo execution time limit in seconds after encountering first compiling error1 is default0 means no limitCARGO_ASC
false is defaultCARGO_FORCE_WARN
false is defaultCARGO_DEPS_WARN
false is defaultIt's a workaround for this issue. Consider a program: ```rust fn f() -> Result<(), ()> { Ok(()) }
fn main() { let mut i: u32 = 0; i -= 1; f(); println!("Hello world"); } ```
It's counterproductive to read this kind of compiler noise in attempt to run the program:
``
$ cargo run
Compiling hello v0.1.0 (/tmp/hello)
warning: variableiis assigned to, but never used
--> src/main.rs:6:9
|
6 | let mut i: u32 = 0;
| ^^^^^
|
= note:#[warn(unusedvariables)]on by default
= note: consider usingi` instead
warning: value assigned to i is never read
--> src/main.rs:7:5
|
7 | i -= 1;
| ^
|
= note: #[warn(unused_assignments)] on by default
= help: maybe it is overwritten before being read?
warning: unused std::result::Result that must be used
--> src/main.rs:8:5
|
8 | f();
| ^^^^
|
= note: #[warn(unused_must_use)] on by default
= note: this Result may be an Err variant, which should be handled
error: this arithmetic operation will overflow
--> src/main.rs:7:5
|
7 | i -= 1;
| ^^^^^^ attempt to compute 0_u32 - 1_u32 which would overflow
|
= note: #[deny(arithmetic_overflow)] on by default
error: aborting due to previous error; 3 warnings emitted
error: could not compile hello.
To learn more, run the command again with --verbose. ```
All we want on this development iteration is to focus on this error:
``
$ cargo lrun
Compiling hello v0.1.0 (/tmp/hello)
error: this arithmetic operation will overflow
--> src/main.rs:7:5
|
7 | i -= 1;
| ^^^^^^ attempt to compute0u32 - 1u32which would overflow
|
= note:#[deny(arithmetic_overflow)]` on by default
error: could not compile hello.
To learn more, run the command again with --verbose. ```
After fixing it we probably want to see the first warning(s):
``
$ sed -i '/.*i -= 1;/d' src/main.rs
$ CARGO_MSG_LIMIT=1 cargo lrun
Finished dev [unoptimized + debuginfo] target(s) in 0.00s
warning: unused variable:i
--> src/main.rs:6:9
|
6 | let mut i: u32 = 0;
| ^^^^^ help: if this is intentional, prefix it with an underscore:i
|
= note:#[warn(unusedvariables)]` on by default
Running `target/debug/hello`
Hello world ```
MIT/Apache-2.0