Skip to content

Commit

Permalink
Merge pull request #165 from mulkieran/cargo-lints
Browse files Browse the repository at this point in the history
Use Cargo.toml to specify lint policy
  • Loading branch information
mulkieran authored Jul 29, 2024
2 parents 7bf46df + 61b4dba commit 9d18f33
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 22 deletions.
12 changes: 12 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,15 @@ uuid = "1.0.0"
[features]
default = []
deprecated = []

[lints.rust]
warnings = { level = "deny" }
future_incompatible = { level = "deny", priority = 1 }
unused = { level = "deny", priority = 2}
rust_2018_idioms = { level = "deny", priority = 3 }
nonstandard_style = { level = "deny", priority = 4 }

[lints.clippy]
all = { level = "deny" }
cargo = { level = "deny" , priority = 1}
from_over_into = { level = "allow", priority = 2 }
33 changes: 11 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@ endif

IGNORE_ARGS ?=

DENY = -D warnings -D future-incompatible -D unused -D rust_2018_idioms -D nonstandard_style

${HOME}/.cargo/bin/cargo-audit:
cargo install cargo-audit

audit: ${HOME}/.cargo/bin/cargo-audit
PATH=${HOME}/.cargo/bin:${PATH} cargo audit -D warnings

build:
RUSTFLAGS="${DENY}" cargo build
cargo build

build-deprecated:
RUSTFLAGS="${DENY}" cargo build --features=deprecated
cargo build --features=deprecated

check-typos:
typos
Expand All @@ -39,14 +37,14 @@ test-set-lower-bounds:
test -e "${SET_LOWER_BOUNDS}"

verify-dependency-bounds: test-set-lower-bounds
RUSTFLAGS="${DENY}" cargo build ${MANIFEST_PATH_ARGS} --all-features
cargo build ${MANIFEST_PATH_ARGS} --all-features
${SET_LOWER_BOUNDS} ${MANIFEST_PATH_ARGS}
RUSTFLAGS="${DENY}" cargo build ${MANIFEST_PATH_ARGS} --all-features
cargo build ${MANIFEST_PATH_ARGS} --all-features

verify-dependency-bounds-sys: test-set-lower-bounds
RUSTFLAGS="${DENY}" cargo build ${MANIFEST_PATH_ARGS} --all-features
cargo build ${MANIFEST_PATH_ARGS} --all-features
${SET_LOWER_BOUNDS} ${MANIFEST_PATH_ARGS}
RUSTFLAGS="${DENY}" cargo build ${MANIFEST_PATH_ARGS} --all-features
cargo build ${MANIFEST_PATH_ARGS} --all-features

test-compare-fedora-versions:
echo "Testing that COMPARE_FEDORA_VERSIONS environment variable is set to a valid path"
Expand All @@ -56,18 +54,9 @@ check-fedora-versions: test-compare-fedora-versions
${COMPARE_FEDORA_VERSIONS} ${MANIFEST_PATH_ARGS} ${FEDORA_RELEASE_ARGS} ${IGNORE_ARGS}

clippy:
RUSTFLAGS="${DENY}" \
cargo clippy --all-features ${CLIPPY_OPTS} -- \
-D warnings \
-D clippy::cargo \
-D clippy::all \
-A clippy::from_over_into
(cd libblkid-rs-sys && RUSTFLAGS="${DENY}" \
cargo clippy --all-features ${CLIPPY_OPTS} -- \
-D warnings \
-D clippy::cargo \
-D clippy::all)

cargo clippy --all-features ${CLIPPY_OPTS}
(cd libblkid-rs-sys && \
cargo clippy --all-features ${CLIPPY_OPTS})

docs-rust:
cargo doc --no-deps --package libblkid-rs --package libblkid-rs-sys
Expand All @@ -84,10 +73,10 @@ fmt-ci:
cargo fmt -- --check

release:
RUSTFLAGS="${DENY}" cargo build --release
cargo build --release

test:
RUSTFLAGS="${DENY}" RUST_BACKTRACE=1 cargo test
RUST_BACKTRACE=1 cargo test

.PHONY:
build
Expand Down
11 changes: 11 additions & 0 deletions libblkid-rs-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,14 @@ cc = "1.0.45"
default-features = false
features = ["runtime"]
version = "0.69.0"

[lints.rust]
warnings = { level = "deny" }
future_incompatible = { level = "deny", priority = 1 }
unused = { level = "deny", priority = 2}
rust_2018_idioms = { level = "deny", priority = 3 }
nonstandard_style = { level = "deny", priority = 4 }

[lints.clippy]
all = { level = "deny" }
cargo = { level = "deny" , priority = 1}

0 comments on commit 9d18f33

Please sign in to comment.