Skip to content

Commit

Permalink
refactor: use a standardized workspace lint table
Browse files Browse the repository at this point in the history
  • Loading branch information
wmmc88 committed Apr 25, 2024
1 parent b6a24d8 commit f41633b
Show file tree
Hide file tree
Showing 24 changed files with 169 additions and 126 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:

name: Docs

env:
RUSTDOCFLAGS: -D warnings

jobs:
docs:
name: Docs
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/github-dependency-review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ jobs:
uses: actions/dependency-review-action@v4
with:
# AND combinations are currently bugged and must be listed separately: https://github.com/actions/dependency-review-action/issues/263
allow-licenses: MIT, Apache-2.0, BSD-3-Clause, ISC, Unicode-DFS-2016, (MIT OR Apache-2.0) AND Unicode-DFS-2016
# OR combinations are currently bugged and must be listed separately: https://github.com/actions/dependency-review-action/issues/670
allow-licenses: MIT, Apache-2.0, BSD-3-Clause, ISC, Unicode-DFS-2016, (MIT OR Apache-2.0) AND Unicode-DFS-2016, Unlicense OR MIT
# anstyle is licensed as (MIT OR Apache-2.0), but the Github api fails to detect it: https://github.com/rust-cli/anstyle/tree/main/crates/anstyle
allow-dependencies-licenses: 'pkg:cargo/[email protected]'
comment-summary-in-pr: on-failure
Expand Down
32 changes: 32 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,35 @@ wdk-sys = { path = "crates/wdk-sys", version = "0.2.0" }
bindgen = "0.69.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

# Until https://github.com/rust-lang/cargo/issues/12208 is resolved, each package in the workspace needs to explictly
# add the following block to its Cargo manifest in order to enable these global lint configurations:
#
# [lints]
# workspace = true

[workspace.lints.rust]
missing_docs = "warn"
unsafe_op_in_unsafe_fn = "forbid"

[workspace.lints.clippy]
# Lint Groups
all = "deny"
pedantic = "warn"
nursery = "warn"
cargo = "warn"
# Individual Lints
multiple_unsafe_ops_per_block = "forbid"
undocumented_unsafe_blocks = "forbid"
unnecessary_safety_doc = "forbid"

[workspace.lints.rustdoc]
bare_urls = "warn"
broken_intra_doc_links = "warn"
invalid_codeblock_attributes = "warn"
invalid_html_tags = "warn"
invalid_rust_codeblocks = "warn"
missing_crate_level_docs = "warn"
private_intra_doc_links = "warn"
redundant_explicit_links = "warn"
unescaped_backticks = "warn"
1 change: 1 addition & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CARGO_MAKE_SKIP_SLOW_SECONDARY_FLOWS = false
CARGO_MAKE_CLIPPY_ARGS = "--all-targets -- -D warnings"
RUSTFLAGS = "-D warnings"
CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN = "stable"
RUSTDOCFLAGS = "-D warnings"

[tasks.wdk-pre-commit-flow]
description = "Run pre-commit tasks and checks"
Expand Down
3 changes: 3 additions & 0 deletions crates/sample-kmdf-driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ wdk-build.workspace = true
[features]
default = []
nightly = ["wdk-macros/nightly", "wdk/nightly", "wdk-sys/nightly"]

[lints]
workspace = true
2 changes: 2 additions & 0 deletions crates/sample-kmdf-driver/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation
// License: MIT OR Apache-2.0

//! Build script for the `sample-kmdf-driver` crate.
fn main() -> Result<(), wdk_build::ConfigError> {
wdk_build::Config::from_env_auto()?.configure_binary_build()
}
13 changes: 5 additions & 8 deletions crates/sample-kmdf-driver/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
// Copyright (c) Microsoft Corporation
// License: MIT OR Apache-2.0

//! # Sample KMDF Driver
//!
//! This is a sample KMDF driver that demonstrates how to use the crates in
//! windows-driver-rs to create a skeleton of a kmdf driver.
#![no_std]
#![deny(unsafe_op_in_unsafe_fn)]
#![deny(clippy::all)]
#![deny(clippy::pedantic)]
#![deny(clippy::nursery)]
#![deny(clippy::cargo)]
#![deny(clippy::undocumented_unsafe_blocks)]
#![deny(clippy::unnecessary_safety_doc)]
#![deny(clippy::multiple_unsafe_ops_per_block)]

extern crate alloc;

Expand Down
3 changes: 3 additions & 0 deletions crates/wdk-alloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ wdk-sys.workspace = true

[dev-dependencies]
wdk-sys = { workspace = true, features = ["test-stubs"] }

[lints]
workspace = true
18 changes: 0 additions & 18 deletions crates/wdk-alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,6 @@
//! ```
#![no_std]
#![deny(missing_docs)]
#![deny(unsafe_op_in_unsafe_fn)]
#![deny(clippy::all)]
#![deny(clippy::pedantic)]
#![deny(clippy::nursery)]
#![deny(clippy::cargo)]
#![deny(clippy::multiple_unsafe_ops_per_block)]
#![deny(clippy::undocumented_unsafe_blocks)]
#![deny(clippy::unnecessary_safety_doc)]
#![deny(rustdoc::broken_intra_doc_links)]
#![deny(rustdoc::private_intra_doc_links)]
#![deny(rustdoc::missing_crate_level_docs)]
#![deny(rustdoc::invalid_codeblock_attributes)]
#![deny(rustdoc::invalid_html_tags)]
#![deny(rustdoc::invalid_rust_codeblocks)]
#![deny(rustdoc::bare_urls)]
#![deny(rustdoc::unescaped_backticks)]
#![deny(rustdoc::redundant_explicit_links)]

use core::alloc::{GlobalAlloc, Layout};

Expand Down
35 changes: 35 additions & 0 deletions crates/wdk-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,38 @@ rustversion = "1.0.14"

[dev-dependencies]
windows = { version = "0.52.0", features = ["Win32_UI_Shell"] }

# Cannot inherit workspace lints since overriding them is not supported yet: https://github.com/rust-lang/cargo/issues/13157
# [lints]
# workspace = true
#
# Differences from the workspace lints have comments explaining why they are different

[lints.rust]
missing_docs = "warn"
unsafe_op_in_unsafe_fn = "forbid"

[lints.clippy]
# Lint Groups
all = "deny"
pedantic = "warn"
nursery = "warn"
cargo = "warn"
# Individual Lints
# multiple_unsafe_ops_per_block = "forbid"
multiple_unsafe_ops_per_block = "deny" # This is lowered to deny since clap generates allow(clippy::restriction) in its Parser and Args derive macros
# undocumented_unsafe_blocks = "forbid"
undocumented_unsafe_blocks = "deny" # This is lowered to deny since clap generates allow(clippy::restriction) in its Parser and Args derive macros
# unnecessary_safety_doc = "forbid"
unnecessary_safety_doc = "deny" # This is lowered to deny since clap generates allow(clippy::restriction) in its Parser and Args derive macros

[lints.rustdoc]
bare_urls = "warn"
broken_intra_doc_links = "warn"
invalid_codeblock_attributes = "warn"
invalid_html_tags = "warn"
invalid_rust_codeblocks = "warn"
missing_crate_level_docs = "warn"
private_intra_doc_links = "warn"
redundant_explicit_links = "warn"
unescaped_backticks = "warn"
2 changes: 2 additions & 0 deletions crates/wdk-build/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation
// License: MIT OR Apache-2.0

//! Build script for the `wdk-build` crate.
#[rustversion::nightly]
fn main() {
println!("cargo:rustc-cfg=nightly_toolchain");
Expand Down
22 changes: 1 addition & 21 deletions crates/wdk-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,8 @@
//! well strives to allow for all the configuration the WDK allows. This
//! includes being ables to select different WDF versions and different driver
//! models (WDM, KMDF, UMDF).
#![cfg_attr(nightly_toolchain, feature(assert_matches))]
#![deny(missing_docs)]
#![deny(unsafe_op_in_unsafe_fn)]
#![deny(clippy::all)]
#![deny(clippy::pedantic)]
#![deny(clippy::nursery)]
#![deny(clippy::cargo)]
// `wdk-build` is only to be used in build scripts, so binary bloat from multiple depenedency
// versions is not a concern
#![allow(clippy::multiple_crate_versions)]
#![deny(clippy::multiple_unsafe_ops_per_block)]
#![deny(clippy::undocumented_unsafe_blocks)]
#![deny(clippy::unnecessary_safety_doc)]
#![deny(rustdoc::broken_intra_doc_links)]
#![deny(rustdoc::private_intra_doc_links)]
#![deny(rustdoc::missing_crate_level_docs)]
#![deny(rustdoc::invalid_codeblock_attributes)]
#![deny(rustdoc::invalid_html_tags)]
#![deny(rustdoc::invalid_rust_codeblocks)]
#![deny(rustdoc::bare_urls)]
#![deny(rustdoc::unescaped_backticks)]
#![deny(rustdoc::redundant_explicit_links)]

mod bindgen;
mod utils;
Expand Down
33 changes: 33 additions & 0 deletions crates/wdk-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,36 @@ development = [
[features]
default = []
nightly = []

# Cannot inherit workspace lints since overriding them is not supported yet: https://github.com/rust-lang/cargo/issues/13157
# [lints]
# workspace = true
#
# Differences from the workspace lints have comments explaining why they are different

[lints.rust]
missing_docs = "warn"
unsafe_op_in_unsafe_fn = "forbid"

[lints.clippy]
# Lint Groups
all = "deny"
pedantic = "warn"
nursery = "warn"
cargo = "warn"
# Individual Lints
multiple_unsafe_ops_per_block = "forbid"
undocumented_unsafe_blocks = "forbid"
# unnecessary_safety_doc = "forbid"
unnecessary_safety_doc = "deny" # This is lowered to deny to allow overriding it for proc_macros: https://github.com/rust-lang/rust-clippy/issues/12583

[lints.rustdoc]
bare_urls = "warn"
broken_intra_doc_links = "warn"
invalid_codeblock_attributes = "warn"
invalid_html_tags = "warn"
invalid_rust_codeblocks = "warn"
missing_crate_level_docs = "warn"
private_intra_doc_links = "warn"
redundant_explicit_links = "warn"
unescaped_backticks = "warn"
18 changes: 0 additions & 18 deletions crates/wdk-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,6 @@

//! A collection of macros that help make it easier to interact with
//! [`wdk-sys`]'s direct bindings to the Windows Driver Kit (WDK).
#![deny(missing_docs)]
#![deny(unsafe_op_in_unsafe_fn)]
#![deny(clippy::all)]
#![deny(clippy::pedantic)]
#![deny(clippy::nursery)]
#![deny(clippy::cargo)]
#![deny(clippy::multiple_unsafe_ops_per_block)]
#![deny(clippy::undocumented_unsafe_blocks)]
#![deny(clippy::unnecessary_safety_doc)]
#![deny(rustdoc::broken_intra_doc_links)]
#![deny(rustdoc::private_intra_doc_links)]
#![deny(rustdoc::missing_crate_level_docs)]
#![deny(rustdoc::invalid_codeblock_attributes)]
#![deny(rustdoc::invalid_html_tags)]
#![deny(rustdoc::invalid_rust_codeblocks)]
#![deny(rustdoc::bare_urls)]
#![deny(rustdoc::unescaped_backticks)]
#![deny(rustdoc::redundant_explicit_links)]
use std::{
io::{BufReader, Read},
Expand Down
3 changes: 3 additions & 0 deletions crates/wdk-panic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ readme.workspace = true
license.workspace = true
keywords = ["panic-handler", "panic", "panic-impl", "wdk", "windows"]
categories = ["no-std", "hardware-support"]

[lints]
workspace = true
19 changes: 1 addition & 18 deletions crates/wdk-panic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,8 @@
// License: MIT OR Apache-2.0

//! Default Panic Handlers for programs built with the WDK (Windows Drivers Kit)
#![no_std]
#![deny(missing_docs)]
#![deny(unsafe_op_in_unsafe_fn)]
#![deny(clippy::all)]
#![deny(clippy::pedantic)]
#![deny(clippy::nursery)]
#![deny(clippy::cargo)]
#![deny(clippy::multiple_unsafe_ops_per_block)]
#![deny(clippy::undocumented_unsafe_blocks)]
#![deny(clippy::unnecessary_safety_doc)]
#![deny(rustdoc::broken_intra_doc_links)]
#![deny(rustdoc::private_intra_doc_links)]
#![deny(rustdoc::missing_crate_level_docs)]
#![deny(rustdoc::invalid_codeblock_attributes)]
#![deny(rustdoc::invalid_html_tags)]
#![deny(rustdoc::invalid_rust_codeblocks)]
#![deny(rustdoc::bare_urls)]
#![deny(rustdoc::unescaped_backticks)]
#![deny(rustdoc::redundant_explicit_links)]

#[cfg(not(test))]
use core::panic::PanicInfo;
Expand Down
35 changes: 35 additions & 0 deletions crates/wdk-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,38 @@ rustversion = "1.0.14"
default = []
nightly = ["wdk-macros/nightly"]
test-stubs = []

# Cannot inherit workspace lints since overriding them is not supported yet: https://github.com/rust-lang/cargo/issues/13157
# [lints]
# workspace = true
#
# Differences from the workspace lints have comments explaining why they are different

[lints.rust]
missing_docs = "warn"
# unsafe_op_in_unsafe_fn = "forbid"
unsafe_op_in_unsafe_fn = "deny" # This is lowered to deny so that we can opt out of it for generated code

[lints.clippy]
# Lint Groups
all = "deny"
pedantic = "warn"
nursery = "warn"
cargo = "warn"
# Individual Lints
# multiple_unsafe_ops_per_block = "forbid"
multiple_unsafe_ops_per_block = "deny" # This is lowered to deny so that we can opt out of it for generated code
# undocumented_unsafe_blocks = "forbid"
undocumented_unsafe_blocks = "deny" # This is lowered to deny so that we can opt out of it for generated code
unnecessary_safety_doc = "forbid"

[lints.rustdoc]
bare_urls = "warn"
broken_intra_doc_links = "warn"
invalid_codeblock_attributes = "warn"
invalid_html_tags = "warn"
invalid_rust_codeblocks = "warn"
missing_crate_level_docs = "warn"
private_intra_doc_links = "warn"
redundant_explicit_links = "warn"
unescaped_backticks = "warn"
2 changes: 2 additions & 0 deletions crates/wdk-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation
// License: MIT OR Apache-2.0

//! Build script for the `wdk-sys` crate.
use std::{
env,
path::{Path, PathBuf},
Expand Down
18 changes: 0 additions & 18 deletions crates/wdk-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,6 @@
//! Direct bindings to APIs available in the Windows Development Kit (WDK)
#![no_std]
#![deny(missing_docs)]
#![deny(unsafe_op_in_unsafe_fn)]
#![deny(clippy::all)]
#![deny(clippy::pedantic)]
#![deny(clippy::nursery)]
#![deny(clippy::cargo)]
#![deny(clippy::multiple_unsafe_ops_per_block)]
#![deny(clippy::undocumented_unsafe_blocks)]
#![deny(clippy::unnecessary_safety_doc)]
#![deny(rustdoc::broken_intra_doc_links)]
#![deny(rustdoc::private_intra_doc_links)]
#![deny(rustdoc::missing_crate_level_docs)]
#![deny(rustdoc::invalid_codeblock_attributes)]
#![deny(rustdoc::invalid_html_tags)]
#![deny(rustdoc::invalid_rust_codeblocks)]
#![deny(rustdoc::bare_urls)]
#![deny(rustdoc::unescaped_backticks)]
#![deny(rustdoc::redundant_explicit_links)]

mod constants;
mod types;
Expand Down
3 changes: 3 additions & 0 deletions crates/wdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ wdk-sys = { workspace = true, features = ["test-stubs"] }
default = ["alloc"]
alloc = []
nightly = ["wdk-sys/nightly"]

[lints]
workspace = true
2 changes: 2 additions & 0 deletions crates/wdk/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation
// License: MIT OR Apache-2.0

//! Build script for the `wdk` crate.
fn main() -> Result<(), wdk_build::ConfigError> {
// Re-export config from wdk-sys
Ok(wdk_build::Config::from_env_auto()?.export_config()?)
Expand Down
Loading

0 comments on commit f41633b

Please sign in to comment.