Skip to content

Commit

Permalink
Merge pull request #929 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 4b49da9 + d901489 commit 5c570aa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
12 changes: 11 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,20 @@ path = "./devicemapper-rs-sys"
semver = "1.0.0"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [
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 }
unexpected_cfgs = { level = "deny", check-cfg = [
'cfg(devicemapper41supported)',
'cfg(devicemapper42supported)',
'cfg(devicemapper437supported)',
'cfg(devicemapper441supported)',
'cfg(devicemapper46supported)'
] }

[lints.clippy]
all = { level = "deny" }
cargo = { level = "deny" , priority = 1}
multiple-crate-versions = { level = "allow", priority = 2 }
24 changes: 8 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ endif

IGNORE_ARGS ?=

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

CLIPPY_DENY = -D clippy::all -D clippy::cargo -A clippy::multiple-crate-versions

audit:
cargo audit -D warnings

Expand All @@ -32,9 +28,9 @@ test-set-lower-bounds:
test -e "${SET_LOWER_BOUNDS}"

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

test-compare-fedora-versions:
echo "Testing that COMPARE_FEDORA_VERSIONS environment variable is set to a valid path"
Expand All @@ -52,24 +48,20 @@ fmt-ci:
cd devicemapper-rs-sys && cargo fmt -- --check

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

build-tests:
RUSTFLAGS="${DENY}" cargo test --no-run
cargo test --no-run

test:
RUSTFLAGS="${DENY}" RUST_BACKTRACE=1 cargo test -- --skip sudo_ --skip loop_
RUST_BACKTRACE=1 cargo test -- --skip sudo_ --skip loop_

sudo_test:
RUSTFLAGS="${DENY}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo test
RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo test

clippy:
RUSTFLAGS="${DENY}" \
cargo clippy --all-features ${CLIPPY_OPTS} -- \
${CLIPPY_DENY}
cd devicemapper-rs-sys && RUSTFLAGS="${DENY}" \
cargo clippy --all-features ${CLIPPY_OPTS} -- \
${CLIPPY_DENY}
cargo clippy --all-features ${CLIPPY_OPTS}
(cd devicemapper-rs-sys && cargo clippy --all-features ${CLIPPY_OPTS})

docs:
cargo doc --no-deps
Expand Down
12 changes: 12 additions & 0 deletions devicemapper-rs-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,15 @@ categories = ["os::linux-apis", "external-ffi-bindings"]
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}
multiple-crate-versions = { level = "allow", priority = 2 }

0 comments on commit 5c570aa

Please sign in to comment.