set -euo pipefail
SCOPE_NO_WS=${SCOPE:-}
readonly SCOPE=${@:---workspace}
RUST_TOOLCHAIN=$(sed -n 's/^[[:space:]]*channel[[:space:]]*=[[:space:]]*"\(.*\)".*/\1/p' \
"$(dirname "$0")/../rust-toolchain.toml")
if [ -z "${RUST_TOOLCHAIN}" ]; then
echo "bin/check: could not read [toolchain] channel from rust-toolchain.toml" >&2
exit 1
fi
readonly RUST_TOOLCHAIN
set -x
cargo +"${RUST_TOOLCHAIN}" fmt --all -- --check
cargo run -p checks
cargo clippy $SCOPE --lib --no-deps --all-features -- -D warnings
cargo clippy $SCOPE --bins --tests --benches --examples --no-deps --all-features -- -D warnings -A missing_docs
cargo doc $SCOPE --no-deps --all-features
cargo deny $SCOPE --all-features check all
cargo machete $SCOPE_NO_WS --with-metadata
cargo vet $SCOPE_NO_WS || true
cargo nextest run $SCOPE --all-features --no-tests=pass
cargo test $SCOPE --doc --all-features
cargo build $SCOPE --all-targets --all-features