Skip to content

Commit

Permalink
Cleanup lints by moving them to the workspace configuration (#706)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbb committed Feb 20, 2024
2 parents ea22638 + f3892d0 commit e0bf71b
Show file tree
Hide file tree
Showing 29 changed files with 51 additions and 180 deletions.
23 changes: 23 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,25 @@ sign-tag = true
tag = false

[workspace.lints.rust]
missing_docs = "warn"
rust_2018_idioms = "warn"
trivial_casts = "warn"
trivial_numeric_casts = "warn"
unused_extern_crates = "warn"
unused_import_braces = "warn"
unused_qualifications = "warn"
variant_size_differences = "warn"
# Unsafe code is needed for array initialization using MaybeUninit.
# unsafe_code = "forbid"

[workspace.lints.clippy]
# These lints have false positives and are disabled until they are fixed.

# explicit_auto_deref suggests code that does not compile
# https://github.com/rust-lang/rust-clippy/issues/9841
explicit_auto_deref = "allow"

# alloc_instead_of_core = "warn"
# Checks for usage of `cloned()` on an `Iterator` or `Option` where `copied()` could be used instead.
cloned_instead_of_copied = "warn"
# Checks for literal calls to `Default::default()`.
Expand All @@ -35,3 +52,9 @@ default_trait_access = "warn"
# doc_markdown = "warn"
# Checks for closures which only invoke a method on the closure argument and can be replaced by referencing the method directly.
redundant_closure_for_method_calls = "warn"
semicolon_if_nothing_returned = "warn"
# std_instead_of_core = "warn"
# std_instead_of_alloc = "warn"

[workspace.lints.rustdoc]
missing_crate_level_docs = "warn"
12 changes: 2 additions & 10 deletions serde_with/src/de/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ use indexmap_2::{IndexMap as IndexMap2, IndexSet as IndexSet2};
type BoxedSlice<T> = Box<[T]>;

pub(crate) mod macros {
// The unused_import lint has false-positives around macros
// The unused_imports lint has false-positives around macros
// https://github.com/rust-lang/rust/issues/78894
#![allow(unused_import)]
#![allow(unused_imports)]

macro_rules! foreach_map {
($m:ident) => {
Expand Down Expand Up @@ -378,10 +378,6 @@ macro_rules! seq_impl {
$with_capacity:expr,
$append:ident
) => {
// Fix for clippy regression in macros on stable
// The bug no longer exists on nightly
// https://github.com/rust-lang/rust-clippy/issues/7768
#[allow(clippy::semicolon_if_nothing_returned)]
impl<'de, T, U $(, $typaram)*> DeserializeAs<'de, $ty<T $(, $typaram)*>> for $ty<U $(, $typaram)*>
where
U: DeserializeAs<'de, T>,
Expand Down Expand Up @@ -442,10 +438,6 @@ macro_rules! map_impl {
$ty:ident < K $(: $kbound1:ident $(+ $kbound2:ident)*)*, V $(, $typaram:ident : $bound1:ident $(+ $bound2:ident)*)* >,
$with_capacity:expr
) => {
// Fix for clippy regression in macros on stable
// The bug no longer exists on nightly
// https://github.com/rust-lang/rust-clippy/issues/7768
#[allow(clippy::semicolon_if_nothing_returned)]
impl<'de, K, V, KU, VU $(, $typaram)*> DeserializeAs<'de, $ty<K, V $(, $typaram)*>> for $ty<KU, VU $(, $typaram)*>
where
KU: DeserializeAs<'de, K>,
Expand Down
27 changes: 0 additions & 27 deletions serde_with/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
#![warn(
clippy::semicolon_if_nothing_returned,
// New clippy lints, not yet stable
// clippy::std_instead_of_core,
// clippy::std_instead_of_alloc,
// clippy::alloc_instead_of_core,
missing_docs,
rust_2018_idioms,
rustdoc::missing_crate_level_docs,
trivial_casts,
trivial_numeric_casts,
unused_extern_crates,
unused_import_braces,
unused_qualifications,
variant_size_differences,
)]
#![doc(test(attr(forbid(unsafe_code))))]
#![doc(test(attr(deny(
missing_debug_implementations,
Expand All @@ -30,17 +14,6 @@
#![doc(test(no_crate_inject))]
#![doc(html_root_url = "https://docs.rs/serde_with/3.6.1/")]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![allow(
// clippy is broken and shows wrong warnings
// clippy on stable does not know yet about the lint name
unknown_lints,
// https://github.com/rust-lang/rust-clippy/issues/8560
clippy::only_used_in_recursion,
// https://github.com/rust-lang/rust-clippy/issues/8867
clippy::derive_partial_eq_without_eq,
// https://github.com/rust-lang/rust-clippy/issues/9101
clippy::explicit_auto_deref
)]
#![no_std]

//! [![crates.io badge](https://img.shields.io/crates/v/serde_with.svg)](https://crates.io/crates/serde_with/)
Expand Down
4 changes: 2 additions & 2 deletions serde_with/src/ser/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ type BoxedSlice<T> = Box<[T]>;
type Slice<T> = [T];

pub(crate) mod macros {
// The unused_import lint has false-positives around macros
// The unused_imports lint has false-positives around macros
// https://github.com/rust-lang/rust/issues/78894
#![allow(unused_import)]
#![allow(unused_imports)]

macro_rules! foreach_map {
($m:ident) => {
Expand Down
1 change: 0 additions & 1 deletion serde_with/src/serde_conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ macro_rules! serde_conv {
$vis struct $m;

const _:() = {
#[allow(clippy::ptr_arg)]
impl $m {
$vis fn serialize<S>(x: &$t, serializer: S) -> $crate::__private__::Result<S::Ok, S::Error>
where
Expand Down
3 changes: 0 additions & 3 deletions serde_with/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,6 @@ where
// TODO could be simplified with nightly maybe_uninit_uninit_array feature
// https://doc.rust-lang.org/nightly/std/mem/union.MaybeUninit.html#method.uninit_array

// Clippy is broken and has a false positive here
// https://github.com/rust-lang/rust-clippy/issues/10551
#[allow(clippy::uninit_assumed_init)]
let mut arr: [MaybeUninit<T>; N] = unsafe { MaybeUninit::uninit().assume_init() };

// Dropping a `MaybeUninit` does nothing. Thus using raw pointer
Expand Down
5 changes: 0 additions & 5 deletions serde_with/tests/base64.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
#![allow(
// clippy is broken and shows wrong warnings
// clippy on stable does not know yet about the lint name
unknown_lints,
// https://github.com/rust-lang/rust-clippy/issues/8867
clippy::derive_partial_eq_without_eq,
// This allows the tests to be written more uniform and not have to special case the last clone().
clippy::redundant_clone,
)]
Expand Down
8 changes: 0 additions & 8 deletions serde_with/tests/chrono_0_4.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#![allow(
// clippy is broken and shows wrong warnings
// clippy on stable does not know yet about the lint name
unknown_lints,
// https://github.com/rust-lang/rust-clippy/issues/8867
clippy::derive_partial_eq_without_eq,
)]

extern crate alloc;

mod utils;
Expand Down
8 changes: 0 additions & 8 deletions serde_with/tests/derives/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#![allow(
// clippy is broken and shows wrong warnings
// clippy on stable does not know yet about the lint name
unknown_lints,
// https://github.com/rust-lang/rust-clippy/issues/8867
clippy::derive_partial_eq_without_eq,
)]

mod deserialize_fromstr;
mod serialize_display;
#[path = "../utils.rs"]
Expand Down
10 changes: 1 addition & 9 deletions serde_with/tests/hashbrown_0_14.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#![allow(
// clippy is broken and shows wrong warnings
// clippy on stable does not know yet about the lint name
unknown_lints,
// https://github.com/rust-lang/rust-clippy/issues/8867
clippy::derive_partial_eq_without_eq,
)]

mod utils;

use crate::utils::{check_deserialization, check_error_deserialization, is_equal};
Expand Down Expand Up @@ -235,7 +227,7 @@ fn duplicate_value_last_wins_hashset() {
where
H: std::hash::Hasher,
{
self.0.hash(state)
self.0.hash(state);
}
}

Expand Down
8 changes: 0 additions & 8 deletions serde_with/tests/hex.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#![allow(
// clippy is broken and shows wrong warnings
// clippy on stable does not know yet about the lint name
unknown_lints,
// https://github.com/rust-lang/rust-clippy/issues/8867
clippy::derive_partial_eq_without_eq,
)]

mod utils;

use crate::utils::{check_deserialization, check_error_deserialization, is_equal};
Expand Down
10 changes: 1 addition & 9 deletions serde_with/tests/indexmap_1.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#![allow(
// clippy is broken and shows wrong warnings
// clippy on stable does not know yet about the lint name
unknown_lints,
// https://github.com/rust-lang/rust-clippy/issues/8867
clippy::derive_partial_eq_without_eq,
)]

mod utils;

use crate::utils::{check_deserialization, check_error_deserialization, is_equal};
Expand Down Expand Up @@ -195,7 +187,7 @@ fn duplicate_value_last_wins_indexset() {
where
H: std::hash::Hasher,
{
self.0.hash(state)
self.0.hash(state);
}
}

Expand Down
10 changes: 1 addition & 9 deletions serde_with/tests/indexmap_2.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#![allow(
// clippy is broken and shows wrong warnings
// clippy on stable does not know yet about the lint name
unknown_lints,
// https://github.com/rust-lang/rust-clippy/issues/8867
clippy::derive_partial_eq_without_eq,
)]

mod utils;

use crate::utils::{check_deserialization, check_error_deserialization, is_equal};
Expand Down Expand Up @@ -195,7 +187,7 @@ fn duplicate_value_last_wins_indexset() {
where
H: std::hash::Hasher,
{
self.0.hash(state)
self.0.hash(state);
}
}

Expand Down
8 changes: 0 additions & 8 deletions serde_with/tests/json.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#![allow(
// clippy is broken and shows wrong warnings
// clippy on stable does not know yet about the lint name
unknown_lints,
// https://github.com/rust-lang/rust-clippy/issues/8867
clippy::derive_partial_eq_without_eq,
)]

mod utils;

use crate::utils::is_equal;
Expand Down
12 changes: 2 additions & 10 deletions serde_with/tests/rust.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#![allow(
// clippy is broken and shows wrong warnings
// clippy on stable does not know yet about the lint name
unknown_lints,
// https://github.com/rust-lang/rust-clippy/issues/8867
clippy::derive_partial_eq_without_eq,
)]

extern crate alloc;

mod utils;
Expand Down Expand Up @@ -218,7 +210,7 @@ fn duplicate_value_first_wins_hashset() {
where
H: std::hash::Hasher,
{
self.0.hash(state)
self.0.hash(state);
}
}

Expand Down Expand Up @@ -279,7 +271,7 @@ fn duplicate_value_last_wins_hashset() {
where
H: std::hash::Hasher,
{
self.0.hash(state)
self.0.hash(state);
}
}

Expand Down
6 changes: 3 additions & 3 deletions serde_with/tests/schemars_0_8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ mod array {
fn test_oob_item() {
check_matches_schema::<FixedArray>(&json!({
"array": [-1, 0x1_0000_0000i64, 32]
}))
}));
}
}

Expand Down Expand Up @@ -417,15 +417,15 @@ mod bool_from_int {
fn test_fractional_value_strict() {
check_matches_schema::<BoolStrict>(&json!({
"value": 0.5
}))
}));
}

#[test]
#[should_panic]
fn test_fractional_value_flexible() {
check_matches_schema::<BoolFlexible>(&json!({
"value": 0.5
}))
}));
}
}

Expand Down
8 changes: 0 additions & 8 deletions serde_with/tests/serde_as/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#![allow(
// clippy is broken and shows wrong warnings
// clippy on stable does not know yet about the lint name
unknown_lints,
// https://github.com/rust-lang/rust-clippy/issues/8867
clippy::derive_partial_eq_without_eq,
)]

extern crate alloc;

mod collections;
Expand Down
8 changes: 0 additions & 8 deletions serde_with/tests/time_0_3.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#![allow(
// clippy is broken and shows wrong warnings
// clippy on stable does not know yet about the lint name
unknown_lints,
// https://github.com/rust-lang/rust-clippy/issues/8867
clippy::derive_partial_eq_without_eq,
)]

mod utils;

use crate::utils::{check_deserialization, check_error_deserialization, is_equal};
Expand Down
2 changes: 1 addition & 1 deletion serde_with/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ where
&serde_json::from_str::<T>(deserialize_from)
.unwrap_err()
.to_string(),
)
);
}

#[track_caller]
Expand Down
6 changes: 1 addition & 5 deletions serde_with/tests/version_numbers.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// Needed to suppress a 2021 incompatibility warning in the macro generated code
// The non_fmt_panic lint is not yet available on most Rust versions
#![allow(unknown_lints, non_fmt_panics)]

use version_sync::{assert_contains_regex, assert_html_root_url_updated};

#[test]
Expand Down Expand Up @@ -60,7 +56,7 @@ fn test_docs_rs_url_point_to_current_version() -> Result<(), Box<dyn std::error:
line_number + 1,
pkg_version,
capture.get(0).expect("Group 0 always exists").as_str()
)
);
}
_ => {}
}
Expand Down
8 changes: 0 additions & 8 deletions serde_with/tests/with_prefix.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#![allow(
// clippy is broken and shows wrong warnings
// clippy on stable does not know yet about the lint name
unknown_lints,
// https://github.com/rust-lang/rust-clippy/issues/8867
clippy::derive_partial_eq_without_eq,
)]

extern crate alloc;

mod utils;
Expand Down
Loading

0 comments on commit e0bf71b

Please sign in to comment.