From 617428e98855d072acd9d332b9782b4159dadfd8 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Fri, 2 Aug 2024 21:38:56 +0700 Subject: [PATCH] Use workspace lints to control unexpected_cfgs. (#682) By using `workspace.lints`, we can configure lints once for everything (and then inherit it into the various crates). The lint configuration for `unexpected_cfgs` works in 1.80+ and warns otherwise. Co-authored-by: Thierry Berger --- Cargo.toml | 8 ++++++++ crates/rapier2d-f64/Cargo.toml | 3 +++ crates/rapier2d/Cargo.toml | 3 +++ crates/rapier3d-f64/Cargo.toml | 3 +++ crates/rapier3d/Cargo.toml | 3 +++ crates/rapier_testbed2d-f64/Cargo.toml | 3 +++ crates/rapier_testbed2d/Cargo.toml | 3 +++ crates/rapier_testbed3d-f64/Cargo.toml | 3 +++ crates/rapier_testbed3d/Cargo.toml | 3 +++ src/lib.rs | 1 - src_testbed/lib.rs | 1 - 11 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fd160594d..1c60f458b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,14 @@ members = ["crates/rapier2d", "crates/rapier2d-f64", "crates/rapier_testbed2d", "crates/rapier3d", "crates/rapier3d-f64", "crates/rapier_testbed3d", "crates/rapier_testbed3d-f64", "examples3d", "examples3d-f64", "benchmarks3d", "crates/rapier3d-urdf", "crates/rapier3d-stl"] resolver = "2" +[workspace.lints] +rust.unexpected_cfgs = { level = "warn", check-cfg = [ + 'cfg(feature, values("dim2", "dim3", "f32", "f64"))', + # The `other-backends` feature isn't in the tested3d-f64 + # but easier to just ignore it here. + 'cfg(feature, values("other-backends"))', +] } + [patch.crates-io] #wrapped2d = { git = "https://github.com/Bastacyclop/rust_box2d.git" } #xurdf = { path = "../xurdf/xurdf" } diff --git a/crates/rapier2d-f64/Cargo.toml b/crates/rapier2d-f64/Cargo.toml index 2a25f480d..49fe36e0a 100644 --- a/crates/rapier2d-f64/Cargo.toml +++ b/crates/rapier2d-f64/Cargo.toml @@ -21,6 +21,9 @@ edition = "2021" [badges] maintenance = { status = "actively-developed" } +[lints] +workspace = true + [features] default = ["dim2", "f64"] dim2 = [] diff --git a/crates/rapier2d/Cargo.toml b/crates/rapier2d/Cargo.toml index 0264f5fb9..b910304cf 100644 --- a/crates/rapier2d/Cargo.toml +++ b/crates/rapier2d/Cargo.toml @@ -21,6 +21,9 @@ edition = "2021" [badges] maintenance = { status = "actively-developed" } +[lints] +workspace = true + [features] default = ["dim2", "f32"] dim2 = [] diff --git a/crates/rapier3d-f64/Cargo.toml b/crates/rapier3d-f64/Cargo.toml index aadd01a98..a56dd6eee 100644 --- a/crates/rapier3d-f64/Cargo.toml +++ b/crates/rapier3d-f64/Cargo.toml @@ -21,6 +21,9 @@ edition = "2021" [badges] maintenance = { status = "actively-developed" } +[lints] +workspace = true + [features] default = ["dim3", "f64"] dim3 = [] diff --git a/crates/rapier3d/Cargo.toml b/crates/rapier3d/Cargo.toml index 77dd8ae8a..25b5bb5ca 100644 --- a/crates/rapier3d/Cargo.toml +++ b/crates/rapier3d/Cargo.toml @@ -21,6 +21,9 @@ edition = "2021" [badges] maintenance = { status = "actively-developed" } +[lints] +workspace = true + [features] default = ["dim3", "f32"] dim3 = [] diff --git a/crates/rapier_testbed2d-f64/Cargo.toml b/crates/rapier_testbed2d-f64/Cargo.toml index 0aa3c56b7..ec56edcce 100644 --- a/crates/rapier_testbed2d-f64/Cargo.toml +++ b/crates/rapier_testbed2d-f64/Cargo.toml @@ -24,6 +24,9 @@ name = "rapier_testbed2d" path = "../../src_testbed/lib.rs" required-features = ["dim2"] +[lints] +workspace = true + [features] default = ["dim2"] dim2 = [] diff --git a/crates/rapier_testbed2d/Cargo.toml b/crates/rapier_testbed2d/Cargo.toml index 436cb2656..6d25ae340 100644 --- a/crates/rapier_testbed2d/Cargo.toml +++ b/crates/rapier_testbed2d/Cargo.toml @@ -24,6 +24,9 @@ name = "rapier_testbed2d" path = "../../src_testbed/lib.rs" required-features = ["dim2"] +[lints] +workspace = true + [features] default = ["dim2"] dim2 = [] diff --git a/crates/rapier_testbed3d-f64/Cargo.toml b/crates/rapier_testbed3d-f64/Cargo.toml index 95091dde0..7462b0764 100644 --- a/crates/rapier_testbed3d-f64/Cargo.toml +++ b/crates/rapier_testbed3d-f64/Cargo.toml @@ -24,6 +24,9 @@ name = "rapier_testbed3d" path = "../../src_testbed/lib.rs" required-features = ["dim3"] +[lints] +workspace = true + [features] default = ["dim3"] dim3 = [] diff --git a/crates/rapier_testbed3d/Cargo.toml b/crates/rapier_testbed3d/Cargo.toml index 9b01ccb73..5a2d8201e 100644 --- a/crates/rapier_testbed3d/Cargo.toml +++ b/crates/rapier_testbed3d/Cargo.toml @@ -24,6 +24,9 @@ name = "rapier_testbed3d" path = "../../src_testbed/lib.rs" required-features = ["dim3"] +[lints] +workspace = true + [features] default = ["dim3"] dim3 = [] diff --git a/src/lib.rs b/src/lib.rs index cf2503d92..8a78e88d9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,7 +15,6 @@ #![allow(clippy::too_many_arguments)] #![allow(clippy::needless_range_loop)] // TODO: remove this? I find that in the math code using indices adds clarity. #![allow(clippy::module_inception)] -#![allow(unexpected_cfgs)] // This happens due to the dim2/dim3/f32/f64 cfg. #[cfg(all(feature = "dim2", feature = "f32"))] pub extern crate parry2d as parry; diff --git a/src_testbed/lib.rs b/src_testbed/lib.rs index e64d025ad..870267380 100644 --- a/src_testbed/lib.rs +++ b/src_testbed/lib.rs @@ -1,5 +1,4 @@ #![allow(clippy::too_many_arguments)] -#![allow(unexpected_cfgs)] // This happens due to the dim2/dim3/f32/f64 cfg. extern crate nalgebra as na;