Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy errors in tests #370

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
toolchain: stable
components: clippy

- run: cargo clippy --workspace --all-features -- -D warnings
- run: cargo clippy --workspace --all-features --all-targets -- -D warnings

rustfmt:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ features = ["full"]
rustdoc-args = ["--cfg", "docsrs"]

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(ci)'] }
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(ci)", "cfg(msrv)", "cfg(nightly)"] }

[features]
default = ["std"]
Expand Down
2 changes: 1 addition & 1 deletion examples/deny_missing_docs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Some docs

#![deny(missing_docs)]
#![allow(dead_code)] // for illustration purposes

use derive_more::{
Add, AddAssign, Constructor, Deref, DerefMut, Display, From, FromStr, Index,
Expand Down Expand Up @@ -33,7 +34,6 @@ pub struct MyBoxedInt(Box<i32>);
pub struct MyVec(Vec<i32>);

/// Some docs
#[allow(dead_code)]
#[derive(Clone, Copy, TryInto)]
#[derive(IsVariant)]
enum MixedInts {
Expand Down
2 changes: 1 addition & 1 deletion impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ features = ["full"]
rustdoc-args = ["--cfg", "docsrs"]

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(ci)'] }
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(ci)", "cfg(nighthly)"] }

[features]
default = []
Expand Down
3 changes: 1 addition & 2 deletions impl/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ where
mod fmt_attribute_spec {
use itertools::Itertools as _;
use quote::ToTokens;
use syn;

use super::FmtAttribute;

Expand Down Expand Up @@ -574,7 +573,7 @@ mod placeholder_parse_fmt_string_spec {
fn indicates_position_and_trait_name_for_each_fmt_placeholder() {
let fmt_string = "{},{:?},{{}},{{{1:0$}}}-{2:.1$x}{par:#?}{:width$}";
assert_eq!(
Placeholder::parse_fmt_string(&fmt_string),
Placeholder::parse_fmt_string(fmt_string),
vec![
Placeholder {
arg: Parameter::Positional(0),
Expand Down
1 change: 1 addition & 0 deletions impl/src/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ impl<'a> Expansion<'a> {
let tys: Vec<_> = fields_tys.validate_type(out_ty)?.collect();

Ok(quote! {
#[allow(clippy::unused_unit)]
#[automatically_derived]
impl #impl_gens derive_more::core::convert::From<#r #lf #m #input_ident #ty_gens>
for ( #( #r #lf #m #tys ),* ) #where_clause
Expand Down
3 changes: 1 addition & 2 deletions impl/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![cfg_attr(
not(all(feature = "add", feature = "mul")),
allow(dead_code),
allow(unused_mut)
allow(dead_code, unused_mut)
)]

use proc_macro2::TokenStream;
Expand Down
2 changes: 1 addition & 1 deletion tests/add.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(dead_code)]
#![allow(dead_code)] // some code is tested for type checking only

use derive_more::Add;

Expand Down
2 changes: 1 addition & 1 deletion tests/add_assign.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(dead_code)]
#![allow(dead_code)] // some code is tested for type checking only

use derive_more::AddAssign;

Expand Down
3 changes: 2 additions & 1 deletion tests/as_mut.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(dead_code, clippy::unnecessary_mut_passed)]
#![allow(clippy::unnecessary_mut_passed)] // testing correct signatures rather than actual code
#![allow(dead_code)] // some code is tested for type checking only

#[cfg(not(feature = "std"))]
extern crate alloc;
Expand Down
2 changes: 1 addition & 1 deletion tests/as_ref.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(dead_code)]
#![allow(dead_code)] // some code is tested for type checking only

#[cfg(not(feature = "std"))]
extern crate alloc;
Expand Down
1 change: 1 addition & 0 deletions tests/boats_display_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fn tuple_struct() {
assert_eq!(s, "Error code: 2");
}

#[allow(clippy::enum_variant_names)] // because of the original source
#[derive(Display)]
enum EnumError {
#[display("Error code: {}", code)]
Expand Down
2 changes: 1 addition & 1 deletion tests/constructor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(dead_code)]
#![allow(dead_code)] // some code is tested for type checking only

use derive_more::Constructor;

Expand Down
28 changes: 14 additions & 14 deletions tests/debug.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(dead_code)]
#![allow(dead_code)] // some code is tested for type checking only

#[cfg(not(feature = "std"))]
extern crate alloc;
Expand Down Expand Up @@ -53,8 +53,8 @@ mod structs {
use derive_more::Debug;

const I32: i32 = 11;
const F64: f64 = 3.14;
const POINTER: &f64 = &3.14;
const F64: f64 = 3.15;
const POINTER: &f64 = &3.15;

#[derive(Debug)]
#[debug("{I32}")]
Expand Down Expand Up @@ -100,8 +100,8 @@ mod structs {
assert_eq!(format!("{:07?}", Octal), "0000013");
assert_eq!(format!("{:03?}", LowerHex), "00b");
assert_eq!(format!("{:03?}", UpperHex), "00B");
assert_eq!(format!("{:07?}", LowerExp), "03.14e0");
assert_eq!(format!("{:07?}", UpperExp), "03.14E0");
assert_eq!(format!("{:07?}", LowerExp), "03.15e0");
assert_eq!(format!("{:07?}", UpperExp), "03.15E0");
assert_eq!(format!("{:018?}", Pointer).len(), 18);
}

Expand All @@ -113,7 +113,7 @@ mod structs {
use derive_more::Debug;

const I32: i32 = 11;
const F64: f64 = 3.14;
const F64: f64 = 3.15;

#[derive(Debug)]
#[debug("{I32:x?}")]
Expand Down Expand Up @@ -593,7 +593,7 @@ mod structs {
fn assert() {
assert_eq!(format!("{:03?}", TupleOctal(9, 4)), "011");
assert_eq!(
format!("{:.1?}", StructLowerExp { a: 7, b: 3.14 }),
format!("{:.1?}", StructLowerExp { a: 7, b: 3.15 }),
"3.1e0",
);
}
Expand Down Expand Up @@ -642,8 +642,8 @@ mod enums {
use derive_more::Debug;

const I32: i32 = 11;
const F64: f64 = 3.14;
const POINTER: &f64 = &3.14;
const F64: f64 = 3.15;
const POINTER: &f64 = &3.15;

#[derive(Debug)]
enum Unit {
Expand Down Expand Up @@ -675,8 +675,8 @@ mod enums {
assert_eq!(format!("{:07?}", Unit::Octal), "0000013");
assert_eq!(format!("{:03?}", Unit::LowerHex), "00b");
assert_eq!(format!("{:03?}", Unit::UpperHex), "00B");
assert_eq!(format!("{:07?}", Unit::LowerExp), "03.14e0");
assert_eq!(format!("{:07?}", Unit::UpperExp), "03.14E0");
assert_eq!(format!("{:07?}", Unit::LowerExp), "03.15e0");
assert_eq!(format!("{:07?}", Unit::UpperExp), "03.15E0");
assert_eq!(format!("{:018?}", Unit::Pointer).len(), 18);
}

Expand All @@ -688,7 +688,7 @@ mod enums {
use derive_more::Debug;

const I32: i32 = 11;
const F64: f64 = 3.14;
const F64: f64 = 3.15;

#[derive(Debug)]
enum Unit {
Expand Down Expand Up @@ -1069,7 +1069,7 @@ mod enums {
fn assert() {
assert_eq!(format!("{:03?}", Enum::TupleOctal(9, 4)), "011");
assert_eq!(
format!("{:.1?}", Enum::StructLowerExp { a: 7, b: 3.14 }),
format!("{:.1?}", Enum::StructLowerExp { a: 7, b: 3.15 }),
"3.1e0",
);
}
Expand Down Expand Up @@ -1840,7 +1840,7 @@ mod generic {
#[test]
fn assert() {
assert_eq!(format!("{:03?}", Tuple(9)), "011");
assert_eq!(format!("{:.1?}", Struct { a: 9, b: 3.14 }), "3.1e0");
assert_eq!(format!("{:.1?}", Struct { a: 9, b: 3.15 }), "3.1e0");
assert_eq!(format!("{:03?}", Enum::<_, u8, u8>::Debug(7)), "007");
assert_eq!(
format!("{:03?}", Enum::<u8, _, _>::Display { b: 7, c: 8 }),
Expand Down
2 changes: 1 addition & 1 deletion tests/deref.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(dead_code, unused_imports)]
#![allow(dead_code)] // some code is tested for type checking only

#[cfg(not(feature = "std"))]
extern crate alloc;
Expand Down
2 changes: 1 addition & 1 deletion tests/deref_mut.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(dead_code, unused_imports)]
#![allow(dead_code)] // some code is tested for type checking only

#[cfg(not(feature = "std"))]
extern crate alloc;
Expand Down
22 changes: 11 additions & 11 deletions tests/display.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(dead_code, unused_imports)]
#![allow(dead_code)] // some code is tested for type checking only

#[cfg(not(feature = "std"))]
extern crate alloc;
Expand Down Expand Up @@ -91,8 +91,8 @@ mod structs {
use super::*;

const I32: i32 = 11;
const F64: f64 = 3.14;
const POINTER: &f64 = &3.14;
const F64: f64 = 3.15;
const POINTER: &f64 = &3.15;

#[derive(Display)]
#[display("{I32}")]
Expand Down Expand Up @@ -138,8 +138,8 @@ mod structs {
assert_eq!(format!("{:07}", Octal), "0000013");
assert_eq!(format!("{:03}", LowerHex), "00b");
assert_eq!(format!("{:03}", UpperHex), "00B");
assert_eq!(format!("{:07}", LowerExp), "03.14e0");
assert_eq!(format!("{:07}", UpperExp), "03.14E0");
assert_eq!(format!("{:07}", LowerExp), "03.15e0");
assert_eq!(format!("{:07}", UpperExp), "03.15E0");
assert_eq!(format!("{:018}", Pointer).len(), 18);
}
}
Expand All @@ -151,7 +151,7 @@ mod structs {
use super::*;

const I32: i32 = 11;
const F64: f64 = 3.14;
const F64: f64 = 3.15;

#[derive(Display)]
#[display("{I32:x?}")]
Expand Down Expand Up @@ -728,8 +728,8 @@ mod enums {
use super::*;

const I32: i32 = 11;
const F64: f64 = 3.14;
const POINTER: &f64 = &3.14;
const F64: f64 = 3.15;
const POINTER: &f64 = &3.15;

#[derive(Display)]
enum Unit {
Expand Down Expand Up @@ -761,8 +761,8 @@ mod enums {
assert_eq!(format!("{:07}", Unit::Octal), "0000013");
assert_eq!(format!("{:03}", Unit::LowerHex), "00b");
assert_eq!(format!("{:03}", Unit::UpperHex), "00B");
assert_eq!(format!("{:07}", Unit::LowerExp), "03.14e0");
assert_eq!(format!("{:07}", Unit::UpperExp), "03.14E0");
assert_eq!(format!("{:07}", Unit::LowerExp), "03.15e0");
assert_eq!(format!("{:07}", Unit::UpperExp), "03.15E0");
assert_eq!(format!("{:018}", Unit::Pointer).len(), 18);
}
}
Expand All @@ -774,7 +774,7 @@ mod enums {
use super::*;

const I32: i32 = 11;
const F64: f64 = 3.14;
const F64: f64 = 3.15;

#[derive(Display)]
enum Unit {
Expand Down
3 changes: 2 additions & 1 deletion tests/error/derives_for_enums_with_source.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(dead_code)]
#![allow(dead_code)] // some code is tested for type checking only

use super::*;

derive_display!(TestErr);
Expand Down
3 changes: 2 additions & 1 deletion tests/error/derives_for_generic_enums_with_source.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(dead_code)]
#![allow(dead_code)] // some code is tested for type checking only

use super::*;

derive_display!(TestErr, T, E);
Expand Down
3 changes: 2 additions & 1 deletion tests/error/derives_for_generic_structs_with_source.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(dead_code)]
#![allow(dead_code)] // some code is tested for type checking only

use super::*;

#[test]
Expand Down
3 changes: 2 additions & 1 deletion tests/error/derives_for_structs_with_source.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(dead_code)]
#![allow(dead_code)] // some code is tested for type checking only

use super::*;

#[test]
Expand Down
4 changes: 3 additions & 1 deletion tests/error/nightly/derives_for_enums_with_backtrace.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![allow(dead_code)]
// For creating backtraces with different addresses in tests.
#![allow(clippy::redundant_closure, clippy::redundant_closure_call)] // for testing
#![allow(dead_code)] // some code is tested for type checking only

use core::error::{request_ref, request_value};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![allow(dead_code)]
// For creating backtraces with different addresses in tests.
#![allow(clippy::redundant_closure, clippy::redundant_closure_call)] // for testing
#![allow(dead_code)] // some code is tested for type checking only

use core::error::{request_ref, request_value};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![allow(dead_code)]
// For creating backtraces with different addresses in tests.
#![allow(clippy::redundant_closure, clippy::redundant_closure_call)] // for testing
#![allow(dead_code)] // some code is tested for type checking only

use core::error::{request_ref, request_value};

Expand Down
4 changes: 3 additions & 1 deletion tests/error/nightly/derives_for_structs_with_backtrace.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![allow(dead_code)]
// For creating backtraces with different addresses in tests.
#![allow(clippy::redundant_closure, clippy::redundant_closure_call)] // for testing
#![allow(dead_code)] // some code is tested for type checking only

use core::error::{request_ref, request_value};

Expand Down
2 changes: 1 addition & 1 deletion tests/error_tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(nightly, feature(error_generic_member_access, error_in_core))]
#![cfg_attr(nightly, feature(error_generic_member_access))]

mod error;
2 changes: 1 addition & 1 deletion tests/from.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(dead_code)]
#![allow(dead_code)] // some code is tested for type checking only

#[cfg(not(feature = "std"))]
extern crate alloc;
Expand Down
2 changes: 1 addition & 1 deletion tests/from_str.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(dead_code)]
#![allow(dead_code)] // some code is tested for type checking only

#[cfg(not(feature = "std"))]
extern crate alloc;
Expand Down
2 changes: 1 addition & 1 deletion tests/generics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(dead_code, non_camel_case_types)]
#![allow(dead_code)] // some code is tested for type checking only

use derive_more::{
Add, AddAssign, Constructor, Deref, DerefMut, Display, Error, From, FromStr, Index,
Expand Down
2 changes: 1 addition & 1 deletion tests/index.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(dead_code, unused_imports)]
#![allow(dead_code)] // some code is tested for type checking only

#[cfg(not(feature = "std"))]
extern crate alloc;
Expand Down
2 changes: 1 addition & 1 deletion tests/index_mut.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(dead_code, unused_imports)]
#![allow(dead_code)] // some code is tested for type checking only

use derive_more::IndexMut;

Expand Down
Loading