M0.2: workspace lints and lints self-test
Denies unwrap/expect/panic/unreachable/todo/unimplemented, indexing and string slicing, missing docs and unsafe code outside tests. clippy.toml allows them in tests. cargo xtask lints-selftest proves both directions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b10a2a72f9
commit
ec1c72d9ac
7 changed files with 397 additions and 3 deletions
|
|
@ -1,6 +1,39 @@
|
|||
//! Project automation for Lutra, run as `cargo xtask <command>`.
|
||||
//!
|
||||
//! Every subcommand prints what it checks and exits with status 1 and a
|
||||
//! message when the check fails.
|
||||
|
||||
/// Entry point; the subcommands arrive with milestone M0.3.
|
||||
fn main() {
|
||||
println!("xtask");
|
||||
mod lints;
|
||||
mod util;
|
||||
|
||||
use std::process::ExitCode;
|
||||
|
||||
/// Usage text printed for `help` and unknown subcommands.
|
||||
const USAGE: &str = "usage: cargo xtask <command>
|
||||
|
||||
commands:
|
||||
lints-selftest prove that shipped unwrap() fails clippy and test unwrap() passes";
|
||||
|
||||
/// Dispatches to the subcommand named by the first argument.
|
||||
fn main() -> ExitCode {
|
||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||
let Some(command) = args.first() else {
|
||||
println!("{USAGE}");
|
||||
return ExitCode::SUCCESS;
|
||||
};
|
||||
let result = match command.as_str() {
|
||||
"lints-selftest" => lints::selftest(),
|
||||
"help" | "--help" | "-h" => {
|
||||
println!("{USAGE}");
|
||||
Ok(())
|
||||
}
|
||||
other => Err(format!("unknown command `{other}`\n\n{USAGE}")),
|
||||
};
|
||||
match result {
|
||||
Ok(()) => ExitCode::SUCCESS,
|
||||
Err(message) => {
|
||||
eprintln!("xtask: {message}");
|
||||
ExitCode::FAILURE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue