-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Silence annoying rustfmt config warnings
- Loading branch information
Showing
2 changed files
with
32 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,47 @@ | ||
use xshell::cmd; | ||
use std::io::BufRead; | ||
|
||
use duct::cmd; | ||
|
||
fn main() { | ||
// When run locally, results may from actual CI runs triggered by .github/workflows/ci.yml | ||
// - Official CI runs latest stable | ||
// - Local runs use whatever the default Rust is locally | ||
|
||
// See if any code needs to be formatted | ||
cmd!("cargo fmt --all -- --check") | ||
println!("$ cargo fmt --all -- --check"); | ||
let errput = cmd!("cargo", "fmt", "--all", "--", "--check") | ||
.stderr_capture() | ||
.run() | ||
.expect("Please run 'cargo fmt --all' to format your code."); | ||
// Capture stderr, filter out lines starting with "Warning:" that complain about nightly-only | ||
// options in rustfmt.toml -- we can remove this (and maybe switch back to `xshell` instead of | ||
// `duct`) once either rustfmt.toml doesn't cause warnings in stable or nightly rust, or rustfmt | ||
// learns an option to silence warnings provoked by the config file. | ||
errput | ||
.stderr | ||
.lines() | ||
.filter_map(|l| l.ok()) | ||
.filter(|l| !l.starts_with("Warning")) | ||
.for_each(|l| eprintln!("{}", l)); | ||
|
||
// See if clippy has any complaints. | ||
// - Type complexity must be ignored because we use huge templates for queries | ||
// - `-A clippy::manual-strip` strip_prefix support was added in 1.45 | ||
cmd!("cargo clippy --workspace --all-targets --all-features -- -D warnings -A clippy::type_complexity -A clippy::manual-strip") | ||
println!("$ cargo clippy --workspace --all-targets --all-features -- -D warnings -A clippy::type_complexity -A clippy::manual-strip"); | ||
cmd!( | ||
"cargo", | ||
"clippy", | ||
"--workspace", | ||
"--all-targets", | ||
"--all-features", | ||
"--", | ||
"-D", | ||
"warnings", | ||
"-A", | ||
"clippy::type_complexity", | ||
"-A", | ||
"clippy::manual-strip" | ||
) | ||
.run() | ||
.expect("Please fix clippy errors in output above."); | ||
} |