cargo checkUseful for fast feedback when the goal is to surface compiler errors quickly.
Commands for investigating compiler errors, Cargo diagnostics, verbose output, and fix suggestions in Rust CLI projects.
Find, expand, and inspect rustc and Cargo errors faster.
cargo checkUseful for fast feedback when the goal is to surface compiler errors quickly.
cargo build -vHelpful when you need to see more about dependency builds, commands, and build-script activity.
cargo build -vvUseful when debugging build scripts or understanding what Cargo is invoking.
Print messages in JSON form for editor tooling or scripts.
cargo check --message-format=jsonUseful for custom tooling, scripts, or inspecting structured compiler diagnostics.
Use rustc suggestions to fix straightforward issues.
cargo fixCargo can apply a subset of compiler suggestions automatically when they are safe and well understood.
Try fixing code even if the crate currently does not compile cleanly.
cargo fix --broken-codeHelpful when doing broad refactors, but review changes carefully afterward.
Open a detailed explanation for an error code such as E0308.
rustc --explain E0308The Rust error index provides longer explanations and examples for compiler error codes.
cargo build --timingsUseful for troubleshooting unexpectedly slow builds in larger CLI projects.
Examples for recurring Rust CLI compiler issues.
let port: u16 = "3000";This typically triggers a type mismatch error because a string literal cannot be assigned to a numeric variable.
Illustrates a move-related ownership error.
let name = String::from("cli");
let moved = name;
println!("{}", name);After moving `name` into `moved`, using `name` again triggers an ownership error.
Method exists but the trait is not in scope.
use std::fs::File;
fn main() {
let mut file = File::create("out.txt").unwrap();
file.write_all(b"hello").unwrap();
}This commonly fails until `use std::io::Write;` is imported so the trait method is in scope.
Return a compatible `Result` when using the question-mark operator.
use std::fs;
fn load() -> std::io::Result<String> {
let content = fs::read_to_string("Cargo.toml")?;
Ok(content)
}A common mistake is using `?` in a function that does not return a compatible `Result` or `Option`.