Move deny lints to Cargo workspace config

To reduce duplication and make it clearer which denials are then overridden for each crate.
This commit is contained in:
Oliver Hamlet
2025-07-22 19:56:21 +01:00
parent a7f6285a6c
commit fee6504fa8
15 changed files with 147 additions and 482 deletions
+96
View File
@@ -24,6 +24,9 @@ windows = { version = "0.61.1", features = ["Win32_Storage_FileSystem"] }
parameterized-test = { path = "./parameterized-test" }
tempfile = "3.17.1"
[lints]
workspace = true
[workspace]
members = ["cpp", "ffi-errors", "nodejs", "parameterized-test", "python"]
@@ -35,3 +38,96 @@ lto = "thin"
inherits = "release"
opt-level = 2
debug = "limited"
# Deny some rustc lints that are allow-by-default.
[workspace.lints.rust]
ambiguous_negative_literals = "deny"
impl_trait_overcaptures = "deny"
let_underscore_drop = "deny"
missing_copy_implementations = "deny"
missing_debug_implementations = "deny"
non_ascii_idents = "deny"
redundant_imports = "deny"
redundant_lifetimes = "deny"
trivial_casts = "deny"
trivial_numeric_casts = "deny"
unit_bindings = "deny"
unreachable_pub = "deny"
unsafe_code = "deny"
[workspace.lints.clippy]
pedantic = "deny"
allow_attributes = "deny"
as_conversions = "deny"
as_underscore = "deny"
assertions_on_result_states = "deny"
big_endian_bytes = "deny"
cfg_not_test = "deny"
clone_on_ref_ptr = "deny"
create_dir = "deny"
dbg_macro = "deny"
decimal_literal_representation = "deny"
default_numeric_fallback = "deny"
doc_include_without_cfg = "deny"
empty_drop = "deny"
error_impl_error = "deny"
exit = "deny"
exhaustive_enums = "deny"
expect_used = "deny"
filetype_is_file = "deny"
float_cmp_const = "deny"
fn_to_numeric_cast_any = "deny"
get_unwrap = "deny"
host_endian_bytes = "deny"
if_then_some_else_none = "deny"
indexing_slicing = "deny"
infinite_loop = "deny"
integer_division = "deny"
integer_division_remainder_used = "deny"
iter_over_hash_type = "deny"
let_underscore_must_use = "deny"
lossy_float_literal = "deny"
map_err_ignore = "deny"
map_with_unused_argument_over_ranges = "deny"
mem_forget = "deny"
missing_assert_message = "deny"
missing_asserts_for_indexing = "deny"
mixed_read_write_in_expression = "deny"
multiple_inherent_impl = "deny"
multiple_unsafe_ops_per_block = "deny"
mutex_atomic = "deny"
mutex_integer = "deny"
needless_raw_strings = "deny"
non_ascii_literal = "deny"
non_zero_suggestions = "deny"
panic = "deny"
panic_in_result_fn = "deny"
partial_pub_fields = "deny"
pathbuf_init_then_push = "deny"
precedence_bits = "deny"
print_stderr = "deny"
print_stdout = "deny"
rc_buffer = "deny"
rc_mutex = "deny"
redundant_type_annotations = "deny"
ref_patterns = "deny"
rest_pat_in_fully_bound_structs = "deny"
str_to_string = "deny"
string_lit_chars_any = "deny"
string_slice = "deny"
string_to_string = "deny"
suspicious_xor_used_as_pow = "deny"
tests_outside_test_module = "deny"
todo = "deny"
try_err = "deny"
undocumented_unsafe_blocks = "deny"
unimplemented = "deny"
unnecessary_safety_comment = "deny"
unneeded_field_pattern = "deny"
unreachable = "deny"
unused_result_ok = "deny"
unwrap_in_result = "deny"
unwrap_used = "deny"
use_debug = "deny"
verbose_file_reads = "deny"
wildcard_enum_match_arm = "deny"
+3
View File
@@ -15,3 +15,6 @@ cxx-build = "1.0"
[lib]
crate-type = ["staticlib"]
[lints]
workspace = true
+8 -95
View File
@@ -1,102 +1,14 @@
// Deny some rustc lints that are allow-by-default.
#![deny(
ambiguous_negative_literals,
impl_trait_overcaptures,
let_underscore_drop,
missing_copy_implementations,
missing_debug_implementations,
non_ascii_idents,
redundant_imports,
redundant_lifetimes,
trivial_casts,
trivial_numeric_casts,
unit_bindings
// Allow some lints that are denied at the workspace level.
#![allow(
unreachable_pub,
unsafe_code,
clippy::must_use_candidate,
clippy::missing_errors_doc
)]
#![deny(clippy::pedantic)]
// Allow a few clippy pedantic lints.
#![allow(clippy::must_use_candidate)]
#![allow(clippy::missing_errors_doc)]
#![allow(
clippy::unnecessary_box_returns,
reason = "CXX requires many returns to be boxed"
)]
// Selectively deny clippy restriction lints.
#![deny(
clippy::as_conversions,
clippy::as_underscore,
clippy::assertions_on_result_states,
clippy::big_endian_bytes,
clippy::cfg_not_test,
clippy::clone_on_ref_ptr,
clippy::create_dir,
clippy::dbg_macro,
clippy::decimal_literal_representation,
clippy::default_numeric_fallback,
clippy::doc_include_without_cfg,
clippy::empty_drop,
clippy::error_impl_error,
clippy::exit,
clippy::exhaustive_enums,
clippy::expect_used,
clippy::filetype_is_file,
clippy::float_cmp_const,
clippy::fn_to_numeric_cast_any,
clippy::get_unwrap,
clippy::host_endian_bytes,
clippy::if_then_some_else_none,
clippy::indexing_slicing,
clippy::infinite_loop,
clippy::integer_division,
clippy::integer_division_remainder_used,
clippy::iter_over_hash_type,
clippy::let_underscore_must_use,
clippy::lossy_float_literal,
clippy::map_err_ignore,
clippy::map_with_unused_argument_over_ranges,
clippy::mem_forget,
clippy::missing_assert_message,
clippy::missing_asserts_for_indexing,
clippy::mixed_read_write_in_expression,
clippy::multiple_inherent_impl,
clippy::multiple_unsafe_ops_per_block,
clippy::mutex_atomic,
clippy::mutex_integer,
clippy::needless_raw_strings,
clippy::non_ascii_literal,
clippy::non_zero_suggestions,
clippy::panic,
clippy::panic_in_result_fn,
clippy::partial_pub_fields,
clippy::pathbuf_init_then_push,
clippy::precedence_bits,
clippy::print_stderr,
clippy::print_stdout,
clippy::rc_buffer,
clippy::rc_mutex,
clippy::redundant_type_annotations,
clippy::ref_patterns,
clippy::rest_pat_in_fully_bound_structs,
clippy::str_to_string,
clippy::string_lit_chars_any,
clippy::string_slice,
clippy::string_to_string,
clippy::suspicious_xor_used_as_pow,
clippy::tests_outside_test_module,
clippy::todo,
clippy::try_err,
clippy::undocumented_unsafe_blocks,
clippy::unimplemented,
clippy::unnecessary_safety_comment,
clippy::unneeded_field_pattern,
clippy::unreachable,
clippy::unused_result_ok,
clippy::unwrap_in_result,
clippy::unwrap_used,
clippy::use_debug,
clippy::verbose_file_reads,
clippy::wildcard_enum_match_arm
)]
mod database;
mod error;
mod game;
@@ -203,9 +115,10 @@ impl TryFrom<ffi::LogLevel> for libloot::LogLevel {
#[allow(
let_underscore_drop,
missing_debug_implementations,
clippy::allow_attributes,
clippy::multiple_unsafe_ops_per_block,
clippy::needless_lifetimes,
reason = "Required by CXX"
reason = "Required by CXX. clippy::allow_attributes is because CXX doesn't support #[expect(...)]"
)]
#[cxx::bridge(namespace = "loot::rust")]
mod ffi {
+3
View File
@@ -6,3 +6,6 @@ license = "GPL-3.0-or-later"
[dependencies]
libloot = { path = ".." }
[lints]
workspace = true
-93
View File
@@ -1,97 +1,4 @@
// Deny some rustc lints that are allow-by-default.
#![deny(
ambiguous_negative_literals,
impl_trait_overcaptures,
let_underscore_drop,
missing_copy_implementations,
missing_debug_implementations,
non_ascii_idents,
redundant_imports,
redundant_lifetimes,
trivial_casts,
trivial_numeric_casts,
unit_bindings,
unreachable_pub
)]
#![deny(clippy::pedantic)]
#![allow(clippy::missing_errors_doc)]
// Selectively deny clippy restriction lints.
#![deny(
clippy::allow_attributes,
clippy::as_conversions,
clippy::as_underscore,
clippy::assertions_on_result_states,
clippy::big_endian_bytes,
clippy::cfg_not_test,
clippy::clone_on_ref_ptr,
clippy::create_dir,
clippy::dbg_macro,
clippy::decimal_literal_representation,
clippy::default_numeric_fallback,
clippy::doc_include_without_cfg,
clippy::empty_drop,
clippy::error_impl_error,
clippy::exit,
clippy::exhaustive_enums,
clippy::expect_used,
clippy::filetype_is_file,
clippy::float_cmp_const,
clippy::fn_to_numeric_cast_any,
clippy::get_unwrap,
clippy::host_endian_bytes,
clippy::if_then_some_else_none,
clippy::indexing_slicing,
clippy::infinite_loop,
clippy::integer_division,
clippy::integer_division_remainder_used,
clippy::iter_over_hash_type,
clippy::let_underscore_must_use,
clippy::lossy_float_literal,
clippy::map_err_ignore,
clippy::map_with_unused_argument_over_ranges,
clippy::mem_forget,
clippy::missing_assert_message,
clippy::missing_asserts_for_indexing,
clippy::mixed_read_write_in_expression,
clippy::multiple_inherent_impl,
clippy::multiple_unsafe_ops_per_block,
clippy::mutex_atomic,
clippy::mutex_integer,
clippy::needless_raw_strings,
clippy::non_ascii_literal,
clippy::non_zero_suggestions,
clippy::panic,
clippy::panic_in_result_fn,
clippy::partial_pub_fields,
clippy::pathbuf_init_then_push,
clippy::precedence_bits,
clippy::print_stderr,
clippy::print_stdout,
clippy::rc_buffer,
clippy::rc_mutex,
clippy::redundant_type_annotations,
clippy::ref_patterns,
clippy::rest_pat_in_fully_bound_structs,
clippy::str_to_string,
clippy::string_lit_chars_any,
clippy::string_slice,
clippy::string_to_string,
clippy::suspicious_xor_used_as_pow,
clippy::tests_outside_test_module,
clippy::todo,
clippy::try_err,
clippy::undocumented_unsafe_blocks,
clippy::unimplemented,
clippy::unnecessary_safety_comment,
clippy::unneeded_field_pattern,
clippy::unreachable,
clippy::unused_result_ok,
clippy::unwrap_in_result,
clippy::unwrap_used,
clippy::use_debug,
clippy::verbose_file_reads,
clippy::wildcard_enum_match_arm
)]
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct UnsupportedEnumValueError;
+3
View File
@@ -17,3 +17,6 @@ napi-derive = "2.12.2"
[build-dependencies]
napi-build = "2.2.2"
[lints]
workspace = true
+6 -95
View File
@@ -1,98 +1,9 @@
// Deny some rustc lints that are allow-by-default.
#![deny(
ambiguous_negative_literals,
impl_trait_overcaptures,
let_underscore_drop,
missing_copy_implementations,
missing_debug_implementations,
non_ascii_idents,
redundant_imports,
redundant_lifetimes,
trivial_casts,
trivial_numeric_casts,
unit_bindings,
unreachable_pub,
unsafe_code
)]
#![deny(clippy::pedantic)]
#![allow(clippy::missing_errors_doc)]
#![allow(clippy::must_use_candidate)]
#![allow(clippy::needless_pass_by_value)]
// Selectively deny clippy restriction lints.
#![deny(
clippy::allow_attributes,
clippy::as_conversions,
clippy::as_underscore,
clippy::assertions_on_result_states,
clippy::big_endian_bytes,
clippy::clone_on_ref_ptr,
clippy::create_dir,
clippy::dbg_macro,
clippy::decimal_literal_representation,
clippy::default_numeric_fallback,
clippy::doc_include_without_cfg,
clippy::empty_drop,
clippy::error_impl_error,
clippy::exit,
// clippy::exhaustive_enums,
clippy::expect_used,
clippy::filetype_is_file,
clippy::float_cmp_const,
clippy::fn_to_numeric_cast_any,
clippy::get_unwrap,
clippy::host_endian_bytes,
clippy::if_then_some_else_none,
clippy::indexing_slicing,
clippy::infinite_loop,
clippy::integer_division,
clippy::integer_division_remainder_used,
clippy::iter_over_hash_type,
clippy::let_underscore_must_use,
clippy::lossy_float_literal,
clippy::map_err_ignore,
clippy::map_with_unused_argument_over_ranges,
clippy::mem_forget,
clippy::missing_assert_message,
clippy::missing_asserts_for_indexing,
clippy::mixed_read_write_in_expression,
clippy::multiple_inherent_impl,
clippy::multiple_unsafe_ops_per_block,
clippy::mutex_atomic,
clippy::mutex_integer,
clippy::needless_raw_strings,
clippy::non_ascii_literal,
clippy::non_zero_suggestions,
clippy::panic,
clippy::panic_in_result_fn,
clippy::partial_pub_fields,
clippy::pathbuf_init_then_push,
clippy::precedence_bits,
clippy::print_stderr,
clippy::print_stdout,
clippy::rc_buffer,
clippy::rc_mutex,
clippy::redundant_type_annotations,
clippy::ref_patterns,
clippy::rest_pat_in_fully_bound_structs,
clippy::str_to_string,
clippy::string_lit_chars_any,
clippy::string_slice,
clippy::string_to_string,
clippy::suspicious_xor_used_as_pow,
clippy::tests_outside_test_module,
clippy::todo,
clippy::try_err,
clippy::undocumented_unsafe_blocks,
clippy::unimplemented,
clippy::unnecessary_safety_comment,
clippy::unneeded_field_pattern,
clippy::unreachable,
clippy::unused_result_ok,
clippy::unwrap_in_result,
clippy::unwrap_used,
clippy::use_debug,
clippy::verbose_file_reads,
clippy::wildcard_enum_match_arm
// Allow some lints that are denied at the workspace level.
#![allow(
clippy::exhaustive_enums,
clippy::missing_errors_doc,
clippy::must_use_candidate,
clippy::needless_pass_by_value
)]
mod database;
+3
View File
@@ -11,3 +11,6 @@ syn = { version = "2.0.104", features = ["full"] }
[lib]
proc-macro = true
[lints]
workspace = true
+9 -3
View File
@@ -1,3 +1,9 @@
#![allow(
clippy::missing_panics_doc,
clippy::unwrap_used,
clippy::panic,
clippy::wildcard_enum_match_arm
)]
use proc_macro::{TokenStream, TokenTree};
use quote::{ToTokens, format_ident, quote};
use syn::{Expr, ExprLit, FnArg, Ident, ItemConst, ItemFn, Lit, Pat, PatIdent, PatType, parse};
@@ -91,19 +97,19 @@ pub fn generate_tests(item: TokenStream) -> TokenStream {
panic!("Expected an ident for the inner_test_name");
};
let _ = item_iter.next();
drop(item_iter.next());
let TokenTree::Ident(inner_test_param_name) = item_iter.next().unwrap() else {
panic!("Expected an ident for the inner_test_param_name");
};
let _ = item_iter.next();
drop(item_iter.next());
let TokenTree::Ident(const_item_name) = item_iter.next().unwrap() else {
panic!("Expected an ident for the const_item_name");
};
let _ = item_iter.next();
drop(item_iter.next());
let TokenTree::Group(const_item_values) = item_iter.next().unwrap() else {
panic!("Expected a group for the const_item_values");
+3
View File
@@ -14,3 +14,6 @@ libloot = { path = ".." }
libloot-ffi-errors = { path = "../ffi-errors" }
pyo3 = "0.25.0"
pyo3-log = "0.12.4"
[lints]
workspace = true
-95
View File
@@ -1,98 +1,3 @@
// Deny some rustc lints that are allow-by-default.
#![deny(
ambiguous_negative_literals,
impl_trait_overcaptures,
let_underscore_drop,
missing_copy_implementations,
missing_debug_implementations,
non_ascii_idents,
redundant_imports,
redundant_lifetimes,
trivial_casts,
trivial_numeric_casts,
unit_bindings,
unreachable_pub,
unsafe_code
)]
#![deny(clippy::pedantic)]
// Selectively deny clippy restriction lints.
#![deny(
clippy::allow_attributes,
clippy::as_conversions,
clippy::as_underscore,
clippy::assertions_on_result_states,
clippy::big_endian_bytes,
clippy::cfg_not_test,
clippy::clone_on_ref_ptr,
clippy::create_dir,
clippy::dbg_macro,
clippy::decimal_literal_representation,
clippy::default_numeric_fallback,
clippy::doc_include_without_cfg,
clippy::empty_drop,
clippy::error_impl_error,
clippy::exit,
clippy::exhaustive_enums,
clippy::expect_used,
clippy::filetype_is_file,
clippy::float_cmp_const,
clippy::fn_to_numeric_cast_any,
clippy::get_unwrap,
clippy::host_endian_bytes,
clippy::if_then_some_else_none,
clippy::indexing_slicing,
clippy::infinite_loop,
clippy::integer_division,
clippy::integer_division_remainder_used,
clippy::iter_over_hash_type,
clippy::let_underscore_must_use,
clippy::lossy_float_literal,
clippy::map_err_ignore,
clippy::map_with_unused_argument_over_ranges,
clippy::mem_forget,
clippy::missing_assert_message,
clippy::missing_asserts_for_indexing,
clippy::mixed_read_write_in_expression,
clippy::multiple_inherent_impl,
clippy::multiple_unsafe_ops_per_block,
clippy::mutex_atomic,
clippy::mutex_integer,
clippy::needless_raw_strings,
clippy::non_ascii_literal,
clippy::non_zero_suggestions,
clippy::panic,
clippy::panic_in_result_fn,
clippy::partial_pub_fields,
clippy::pathbuf_init_then_push,
clippy::precedence_bits,
clippy::print_stderr,
clippy::print_stdout,
clippy::rc_buffer,
clippy::rc_mutex,
clippy::redundant_type_annotations,
clippy::ref_patterns,
clippy::rest_pat_in_fully_bound_structs,
clippy::str_to_string,
clippy::string_lit_chars_any,
clippy::string_slice,
clippy::string_to_string,
clippy::suspicious_xor_used_as_pow,
clippy::tests_outside_test_module,
clippy::todo,
clippy::try_err,
clippy::undocumented_unsafe_blocks,
clippy::unimplemented,
clippy::unnecessary_safety_comment,
clippy::unneeded_field_pattern,
clippy::unreachable,
clippy::unused_result_ok,
clippy::unwrap_in_result,
clippy::unwrap_used,
clippy::use_debug,
clippy::verbose_file_reads,
clippy::wildcard_enum_match_arm
)]
mod database;
mod error;
mod game;
+9 -97
View File
@@ -1,100 +1,12 @@
// Deny some rustc lints that are allow-by-default.
#![deny(
ambiguous_negative_literals,
impl_trait_overcaptures,
let_underscore_drop,
missing_copy_implementations,
missing_debug_implementations,
non_ascii_idents,
redundant_imports,
redundant_lifetimes,
trivial_casts,
trivial_numeric_casts,
unit_bindings,
// unreachable_pub,
unsafe_code
)]
#![deny(clippy::pedantic)]
// Allow a few clippy pedantic lints.
#![allow(clippy::doc_markdown)]
#![allow(clippy::must_use_candidate)]
#![allow(clippy::missing_errors_doc)]
// Selectively deny clippy restriction lints.
#![deny(
clippy::allow_attributes,
clippy::as_conversions,
clippy::as_underscore,
clippy::assertions_on_result_states,
clippy::big_endian_bytes,
clippy::cfg_not_test,
clippy::clone_on_ref_ptr,
clippy::create_dir,
clippy::dbg_macro,
clippy::decimal_literal_representation,
clippy::default_numeric_fallback,
clippy::doc_include_without_cfg,
clippy::empty_drop,
clippy::error_impl_error,
clippy::exit,
// clippy::exhaustive_enums,
clippy::expect_used,
// clippy::filetype_is_file,
clippy::float_cmp_const,
clippy::fn_to_numeric_cast_any,
clippy::get_unwrap,
clippy::host_endian_bytes,
clippy::if_then_some_else_none,
clippy::indexing_slicing,
clippy::infinite_loop,
clippy::integer_division,
clippy::integer_division_remainder_used,
clippy::iter_over_hash_type,
clippy::let_underscore_must_use,
clippy::lossy_float_literal,
clippy::map_err_ignore,
clippy::map_with_unused_argument_over_ranges,
clippy::mem_forget,
clippy::missing_assert_message,
clippy::missing_asserts_for_indexing,
clippy::mixed_read_write_in_expression,
clippy::multiple_inherent_impl,
clippy::multiple_unsafe_ops_per_block,
clippy::mutex_atomic,
clippy::mutex_integer,
clippy::needless_raw_strings,
clippy::non_ascii_literal,
clippy::non_zero_suggestions,
clippy::panic,
clippy::panic_in_result_fn,
clippy::partial_pub_fields,
clippy::pathbuf_init_then_push,
clippy::precedence_bits,
clippy::print_stderr,
clippy::print_stdout,
clippy::rc_buffer,
clippy::rc_mutex,
clippy::redundant_type_annotations,
clippy::ref_patterns,
clippy::rest_pat_in_fully_bound_structs,
clippy::str_to_string,
clippy::string_lit_chars_any,
clippy::string_slice,
clippy::string_to_string,
clippy::suspicious_xor_used_as_pow,
clippy::tests_outside_test_module,
clippy::todo,
clippy::try_err,
clippy::undocumented_unsafe_blocks,
clippy::unimplemented,
clippy::unnecessary_safety_comment,
clippy::unneeded_field_pattern,
clippy::unreachable,
clippy::unused_result_ok,
clippy::unwrap_in_result,
clippy::unwrap_used,
clippy::use_debug,
clippy::verbose_file_reads,
// clippy::wildcard_enum_match_arm,
// Allow some lints that are denied at the workspace level.
#![allow(
unreachable_pub,
clippy::doc_markdown,
clippy::exhaustive_enums,
clippy::filetype_is_file,
clippy::must_use_candidate,
clippy::missing_errors_doc,
clippy::wildcard_enum_match_arm
)]
#![cfg_attr(
test,
+2 -2
View File
@@ -9,16 +9,16 @@ use crate::{
logging::{self, is_log_enabled},
metadata::Group,
sorting::{
search::find_cycle,
error::{
BuildGroupsGraphError, CyclicInteractionError, PathfindingError, UndefinedGroupError,
},
search::find_cycle,
},
};
use super::{
search::{DfsVisitor, depth_first_search},
error::GroupsPathError,
search::{DfsVisitor, depth_first_search},
};
pub type GroupsGraph = Graph<Box<str>, EdgeType>;
+1 -1
View File
@@ -1,7 +1,7 @@
mod search;
pub mod error;
pub mod groups;
pub mod plugins;
mod search;
mod validate;
pub mod vertex;
+1 -1
View File
@@ -19,8 +19,8 @@ use crate::{
};
use super::{
search::{BidirBfsVisitor, DfsVisitor, bidirectional_bfs, depth_first_search, find_cycle},
groups::GroupsGraph,
search::{BidirBfsVisitor, DfsVisitor, bidirectional_bfs, depth_first_search, find_cycle},
validate::{validate_plugin_groups, validate_specific_and_hardcoded_edges},
};