From 28e81790b9e17614ebf91440c29a0dbc494b6c7c Mon Sep 17 00:00:00 2001 From: tyranron Date: Mon, 17 Jun 2024 12:27:30 +0200 Subject: [PATCH] Corrections and improvements --- Cargo.toml | 2 +- examples/deny_missing_docs.rs | 3 +- impl/Cargo.toml | 2 +- impl/src/into.rs | 2 +- impl/src/utils.rs | 3 +- tests/add.rs | 2 +- tests/add_assign.rs | 2 +- tests/as_mut.rs | 3 +- tests/as_ref.rs | 2 +- tests/boats_display_derive.rs | 2 +- tests/constructor.rs | 2 +- tests/debug.rs | 2 +- tests/deref.rs | 2 +- tests/deref_mut.rs | 2 +- tests/display.rs | 2 +- tests/error/derives_for_enums_with_source.rs | 3 +- .../derives_for_generic_enums_with_source.rs | 3 +- ...derives_for_generic_structs_with_source.rs | 3 +- .../error/derives_for_structs_with_source.rs | 3 +- .../derives_for_enums_with_backtrace.rs | 7 +- ...erives_for_generic_enums_with_backtrace.rs | 7 +- ...ives_for_generic_structs_with_backtrace.rs | 7 +- .../derives_for_structs_with_backtrace.rs | 7 +- tests/from.rs | 2 +- tests/from_str.rs | 2 +- tests/generics.rs | 2 +- tests/index.rs | 2 +- tests/index_mut.rs | 2 +- tests/into.rs | 173 +++++++++--------- tests/into_iterator.rs | 2 +- tests/is_variant.rs | 2 +- tests/mul.rs | 2 +- tests/mul_assign.rs | 2 +- tests/no_std.rs | 2 +- tests/not.rs | 2 +- tests/try_from.rs | 3 +- tests/try_into.rs | 2 +- tests/try_unwrap.rs | 2 +- tests/unwrap.rs | 2 +- 39 files changed, 137 insertions(+), 140 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a2fc0758..420f60b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,7 @@ features = ["full"] rustdoc-args = ["--cfg", "docsrs"] [lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(ci)', 'cfg(nightly)', 'cfg(msrv)'] } +unexpected_cfgs = { level = "warn", check-cfg = ["cfg(ci)", "cfg(msrv)", "cfg(nightly)"] } [features] default = ["std"] diff --git a/examples/deny_missing_docs.rs b/examples/deny_missing_docs.rs index 2a2ada1a..66e0bc8e 100644 --- a/examples/deny_missing_docs.rs +++ b/examples/deny_missing_docs.rs @@ -1,7 +1,7 @@ //! Some docs -#![allow(dead_code)] #![deny(missing_docs)] +#![allow(dead_code)] // for illustration purposes use derive_more::{ Add, AddAssign, Constructor, Deref, DerefMut, Display, From, FromStr, Index, @@ -34,7 +34,6 @@ pub struct MyBoxedInt(Box); pub struct MyVec(Vec); /// Some docs -#[allow(dead_code)] #[derive(Clone, Copy, TryInto)] #[derive(IsVariant)] enum MixedInts { diff --git a/impl/Cargo.toml b/impl/Cargo.toml index 906a49d2..8252fdfb 100644 --- a/impl/Cargo.toml +++ b/impl/Cargo.toml @@ -44,7 +44,7 @@ features = ["full"] rustdoc-args = ["--cfg", "docsrs"] [lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(ci)', 'cfg(nighthly)'] } +unexpected_cfgs = { level = "warn", check-cfg = ["cfg(ci)", "cfg(nighthly)"] } [features] default = [] diff --git a/impl/src/into.rs b/impl/src/into.rs index 034d351c..0f4601d2 100644 --- a/impl/src/into.rs +++ b/impl/src/into.rs @@ -178,8 +178,8 @@ impl<'a> Expansion<'a> { let tys: Vec<_> = fields_tys.validate_type(out_ty)?.collect(); Ok(quote! { - #[automatically_derived] #[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 { diff --git a/impl/src/utils.rs b/impl/src/utils.rs index 5a6649cb..b9543f42 100644 --- a/impl/src/utils.rs +++ b/impl/src/utils.rs @@ -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; diff --git a/tests/add.rs b/tests/add.rs index 4c38fdae..c16a08d0 100644 --- a/tests/add.rs +++ b/tests/add.rs @@ -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; diff --git a/tests/add_assign.rs b/tests/add_assign.rs index 48795851..66b6f859 100644 --- a/tests/add_assign.rs +++ b/tests/add_assign.rs @@ -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; diff --git a/tests/as_mut.rs b/tests/as_mut.rs index f21807fb..969fc82c 100644 --- a/tests/as_mut.rs +++ b/tests/as_mut.rs @@ -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; diff --git a/tests/as_ref.rs b/tests/as_ref.rs index 9ab5daa7..14465c4c 100644 --- a/tests/as_ref.rs +++ b/tests/as_ref.rs @@ -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; diff --git a/tests/boats_display_derive.rs b/tests/boats_display_derive.rs index 533ef000..7bc2830d 100644 --- a/tests/boats_display_derive.rs +++ b/tests/boats_display_derive.rs @@ -35,7 +35,7 @@ fn tuple_struct() { assert_eq!(s, "Error code: 2"); } -#[allow(clippy::enum_variant_names)] +#[allow(clippy::enum_variant_names)] // because of the original source #[derive(Display)] enum EnumError { #[display("Error code: {}", code)] diff --git a/tests/constructor.rs b/tests/constructor.rs index 6199d1d1..8777692b 100644 --- a/tests/constructor.rs +++ b/tests/constructor.rs @@ -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; diff --git a/tests/debug.rs b/tests/debug.rs index 067c6396..15e7f12f 100644 --- a/tests/debug.rs +++ b/tests/debug.rs @@ -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; diff --git a/tests/deref.rs b/tests/deref.rs index 9c6263ea..efdb6d2d 100644 --- a/tests/deref.rs +++ b/tests/deref.rs @@ -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; diff --git a/tests/deref_mut.rs b/tests/deref_mut.rs index 2f0e8929..dab6733f 100644 --- a/tests/deref_mut.rs +++ b/tests/deref_mut.rs @@ -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; diff --git a/tests/display.rs b/tests/display.rs index 711eb473..1e7ddfc1 100644 --- a/tests/display.rs +++ b/tests/display.rs @@ -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; diff --git a/tests/error/derives_for_enums_with_source.rs b/tests/error/derives_for_enums_with_source.rs index d8e5db7d..e5c6c360 100644 --- a/tests/error/derives_for_enums_with_source.rs +++ b/tests/error/derives_for_enums_with_source.rs @@ -1,4 +1,5 @@ -#![allow(dead_code)] +#![allow(dead_code)] // some code is tested for type checking only + use super::*; derive_display!(TestErr); diff --git a/tests/error/derives_for_generic_enums_with_source.rs b/tests/error/derives_for_generic_enums_with_source.rs index 8a7d42de..5067043c 100644 --- a/tests/error/derives_for_generic_enums_with_source.rs +++ b/tests/error/derives_for_generic_enums_with_source.rs @@ -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); diff --git a/tests/error/derives_for_generic_structs_with_source.rs b/tests/error/derives_for_generic_structs_with_source.rs index 65a1ca24..64266367 100644 --- a/tests/error/derives_for_generic_structs_with_source.rs +++ b/tests/error/derives_for_generic_structs_with_source.rs @@ -1,4 +1,5 @@ -#![allow(dead_code)] +#![allow(dead_code)] // some code is tested for type checking only + use super::*; #[test] diff --git a/tests/error/derives_for_structs_with_source.rs b/tests/error/derives_for_structs_with_source.rs index c2b28a82..2267c16e 100644 --- a/tests/error/derives_for_structs_with_source.rs +++ b/tests/error/derives_for_structs_with_source.rs @@ -1,4 +1,5 @@ -#![allow(dead_code)] +#![allow(dead_code)] // some code is tested for type checking only + use super::*; #[test] diff --git a/tests/error/nightly/derives_for_enums_with_backtrace.rs b/tests/error/nightly/derives_for_enums_with_backtrace.rs index 81f285a2..c5f9234a 100644 --- a/tests/error/nightly/derives_for_enums_with_backtrace.rs +++ b/tests/error/nightly/derives_for_enums_with_backtrace.rs @@ -1,7 +1,6 @@ -#![allow(dead_code)] -// Allow redundant closures in tests, because we use them to create backtraces with different -// addresses. -#![allow(clippy::redundant_closure, clippy::redundant_closure_call)] +// 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}; diff --git a/tests/error/nightly/derives_for_generic_enums_with_backtrace.rs b/tests/error/nightly/derives_for_generic_enums_with_backtrace.rs index f312e1d2..7144f91f 100644 --- a/tests/error/nightly/derives_for_generic_enums_with_backtrace.rs +++ b/tests/error/nightly/derives_for_generic_enums_with_backtrace.rs @@ -1,7 +1,6 @@ -#![allow(dead_code)] -// Allow redundant closures in tests, because we use them to create backtraces with different -// addresses. -#![allow(clippy::redundant_closure, clippy::redundant_closure_call)] +// 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}; diff --git a/tests/error/nightly/derives_for_generic_structs_with_backtrace.rs b/tests/error/nightly/derives_for_generic_structs_with_backtrace.rs index b5b0db52..b3b98998 100644 --- a/tests/error/nightly/derives_for_generic_structs_with_backtrace.rs +++ b/tests/error/nightly/derives_for_generic_structs_with_backtrace.rs @@ -1,7 +1,6 @@ -#![allow(dead_code)] -// Allow redundant closures in tests, because we use them to create backtraces with different -// addresses. -#![allow(clippy::redundant_closure, clippy::redundant_closure_call)] +// 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}; diff --git a/tests/error/nightly/derives_for_structs_with_backtrace.rs b/tests/error/nightly/derives_for_structs_with_backtrace.rs index bfa888da..a1432d6c 100644 --- a/tests/error/nightly/derives_for_structs_with_backtrace.rs +++ b/tests/error/nightly/derives_for_structs_with_backtrace.rs @@ -1,7 +1,6 @@ -#![allow(dead_code)] -// Allow redundant closures in tests, because we use them to create backtraces with different -// addresses. -#![allow(clippy::redundant_closure, clippy::redundant_closure_call)] +// 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}; diff --git a/tests/from.rs b/tests/from.rs index e43fa748..48f745fb 100644 --- a/tests/from.rs +++ b/tests/from.rs @@ -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; diff --git a/tests/from_str.rs b/tests/from_str.rs index 64f2848c..65bdd320 100644 --- a/tests/from_str.rs +++ b/tests/from_str.rs @@ -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; diff --git a/tests/generics.rs b/tests/generics.rs index 039e8903..bf968eb5 100644 --- a/tests/generics.rs +++ b/tests/generics.rs @@ -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, diff --git a/tests/index.rs b/tests/index.rs index b972388b..c1c32b70 100644 --- a/tests/index.rs +++ b/tests/index.rs @@ -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; diff --git a/tests/index_mut.rs b/tests/index_mut.rs index cd16cb53..be9668c6 100644 --- a/tests/index_mut.rs +++ b/tests/index_mut.rs @@ -1,4 +1,4 @@ -#![allow(dead_code, unused_imports)] +#![allow(dead_code)] // some code is tested for type checking only use derive_more::IndexMut; diff --git a/tests/into.rs b/tests/into.rs index dddc7a42..7b4cbdff 100644 --- a/tests/into.rs +++ b/tests/into.rs @@ -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; @@ -58,7 +58,8 @@ impl From<&mut Wrapped> for &mut Transmuted { } mod unit { - #![allow(clippy::unit_cmp)] + #![allow(clippy::unit_cmp)] // because of type inference in assertions + use super::*; #[derive(Debug, Into, PartialEq)] @@ -129,7 +130,8 @@ mod single_field { #[test] fn assert() { - #![allow(clippy::unit_cmp)] + #![allow(clippy::unit_cmp)] // because of type inference in assertions + assert_eq!((), Tuple(42).into()); assert_eq!((), Struct { field: 42 }.into()); } @@ -310,7 +312,8 @@ mod single_field { #[test] fn assert() { - #![allow(clippy::unit_cmp)] + #![allow(clippy::unit_cmp)] // because of type inference in assertions + assert_eq!((), Tuple(Wrapped(42)).into()); assert_eq!((), Struct { field: Wrapped(42) }.into()); } @@ -1074,10 +1077,10 @@ mod with_fields { #[test] fn tuple() { - let foo = Tuple(1, 2.0, 3.0); + let t = Tuple(1, 2.0, 3.0); - assert_eq!(1, foo.into()); - assert_eq!(3.0, foo.into()); + assert_eq!(1, t.into()); + assert_eq!(3.0, t.into()); } #[derive(Clone, Copy, Debug, Into)] @@ -1107,14 +1110,14 @@ mod with_fields { #[test] fn named() { - let foo = Struct { + let s = Struct { a: 1, b: 2.0, c: 3.0, }; - assert_eq!(1, foo.into()); - assert_eq!(3.0, foo.into()); + assert_eq!(1, s.into()); + assert_eq!(3.0, s.into()); } mod types { @@ -1145,12 +1148,12 @@ mod with_fields { #[test] fn tuple() { - let foo = Tuple("1".to_owned(), 2.0, 3.0); + let f = Tuple("1".to_owned(), 2.0, 3.0); - assert_eq!(Box::::from("1".to_owned()), foo.clone().into()); - assert_eq!(Cow::Borrowed("1"), Cow::::from(foo.clone())); - assert_eq!(3.0f32, foo.clone().into()); - assert_eq!(3.0f64, foo.into()); + assert_eq!(Box::::from("1".to_owned()), f.clone().into()); + assert_eq!(Cow::Borrowed("1"), Cow::::from(f.clone())); + assert_eq!(3.0f32, f.clone().into()); + assert_eq!(3.0f64, f.into()); } #[derive(Clone, Debug, Into)] @@ -1188,16 +1191,16 @@ mod with_fields { #[test] fn named() { - let foo = Struct { + let s = Struct { a: "1".to_owned(), b: 2.0, c: 3.0, }; - assert_eq!(Box::::from("1".to_owned()), foo.clone().into()); - assert_eq!(Cow::Borrowed("1"), Cow::::from(foo.clone())); - assert_eq!(3.0f32, foo.clone().into()); - assert_eq!(3.0f64, foo.into()); + assert_eq!(Box::::from("1".to_owned()), s.clone().into()); + assert_eq!(Cow::Borrowed("1"), Cow::::from(s.clone())); + assert_eq!(3.0f32, s.clone().into()); + assert_eq!(3.0f64, s.into()); } mod r#ref { @@ -1216,10 +1219,10 @@ mod with_fields { #[test] fn tuple() { - let foo = Tuple("1".to_owned(), 2.0, 3.0); + let t = Tuple("1".to_owned(), 2.0, 3.0); - assert_eq!(&"1".to_owned(), <&String>::from(&foo)); - assert_eq!(&3.0, <&f64>::from(&foo)); + assert_eq!(&"1".to_owned(), <&String>::from(&t)); + assert_eq!(&3.0, <&f64>::from(&t)); } #[derive(Debug, Into)] @@ -1249,14 +1252,14 @@ mod with_fields { #[test] fn named() { - let foo = Struct { + let s = Struct { a: "1".to_owned(), b: 2.0, c: 3.0, }; - assert_eq!(&"1".to_owned(), <&String>::from(&foo)); - assert_eq!(&3.0, <&f64>::from(&foo)); + assert_eq!(&"1".to_owned(), <&String>::from(&s)); + assert_eq!(&3.0, <&f64>::from(&s)); } mod types { @@ -1270,10 +1273,10 @@ mod with_fields { #[test] fn tuple() { - let foo = Tuple(Wrapped(1), Wrapped(2)); + let t = Tuple(Wrapped(1), Wrapped(2)); - assert_eq!(&Transmuted(1), <&Transmuted>::from(&foo)); - assert_eq!(&Wrapped(2), <&Wrapped>::from(&foo)); + assert_eq!(&Transmuted(1), <&Transmuted>::from(&t)); + assert_eq!(&Wrapped(2), <&Wrapped>::from(&t)); } #[derive(Debug, Into)] @@ -1286,13 +1289,13 @@ mod with_fields { #[test] fn named() { - let foo = Struct { + let s = Struct { a: Wrapped(1), b: Wrapped(2), }; - assert_eq!(&Transmuted(1), <&Transmuted>::from(&foo)); - assert_eq!(&Wrapped(2), <&Wrapped>::from(&foo)); + assert_eq!(&Transmuted(1), <&Transmuted>::from(&s)); + assert_eq!(&Wrapped(2), <&Wrapped>::from(&s)); } } @@ -1304,10 +1307,10 @@ mod with_fields { #[test] fn tuple() { - let mut foo = Tuple(1, 2.0, 3.0); + let mut t = Tuple(1, 2.0, 3.0); - assert_eq!(&mut 1, <&mut i32>::from(&mut foo)); - assert_eq!(&mut 3.0, <&mut f64>::from(&mut foo)); + assert_eq!(&mut 1, <&mut i32>::from(&mut t)); + assert_eq!(&mut 3.0, <&mut f64>::from(&mut t)); } #[derive(Debug, Into)] @@ -1321,14 +1324,14 @@ mod with_fields { #[test] fn named() { - let mut foo = Struct { + let mut s = Struct { a: 1, b: 2.0, c: 3.0, }; - assert_eq!(&mut 1, <&mut i32>::from(&mut foo)); - assert_eq!(&mut 3.0, <&mut f64>::from(&mut foo)); + assert_eq!(&mut 1, <&mut i32>::from(&mut s)); + assert_eq!(&mut 3.0, <&mut f64>::from(&mut s)); } mod types { @@ -1342,15 +1345,15 @@ mod with_fields { #[test] fn tuple() { - let mut foo = Tuple(Wrapped(1), Wrapped(2)); + let mut t = Tuple(Wrapped(1), Wrapped(2)); assert_eq!( &mut Transmuted(1), - <&mut Transmuted>::from(&mut foo), + <&mut Transmuted>::from(&mut t), ); assert_eq!( &mut Wrapped(2), - <&mut Wrapped>::from(&mut foo), + <&mut Wrapped>::from(&mut t), ); } @@ -1364,18 +1367,18 @@ mod with_fields { #[test] fn named() { - let mut foo = Struct { + let mut s = Struct { a: Wrapped(1), b: Wrapped(2), }; assert_eq!( &mut Transmuted(1), - <&mut Transmuted>::from(&mut foo), + <&mut Transmuted>::from(&mut s), ); assert_eq!( &mut Wrapped(2), - <&mut Wrapped>::from(&mut foo), + <&mut Wrapped>::from(&mut s), ); } } @@ -1399,14 +1402,14 @@ mod with_fields { #[test] fn tuple() { - let mut foo = Tuple(Wrapped(1), Wrapped(2.0), Wrapped(3.0)); - - assert_eq!(&Transmuted(1), <&Transmuted>::from(&foo)); - assert_eq!(&mut Transmuted(3.0), <&mut Transmuted>::from(&mut foo)); - assert_eq!(&mut Wrapped(3.0), <&mut Wrapped>::from(&mut foo)); - assert_eq!((&Wrapped(1), &Transmuted(3.0)), (&foo).into()); - assert_eq!(&Wrapped(2.0), <&Wrapped>::from(&foo)); - assert_eq!(Wrapped(1), foo.into()); + let mut t = Tuple(Wrapped(1), Wrapped(2.0), Wrapped(3.0)); + + assert_eq!(&Transmuted(1), <&Transmuted>::from(&t)); + assert_eq!(&mut Transmuted(3.0), <&mut Transmuted>::from(&mut t)); + assert_eq!(&mut Wrapped(3.0), <&mut Wrapped>::from(&mut t)); + assert_eq!((&Wrapped(1), &Transmuted(3.0)), (&t).into()); + assert_eq!(&Wrapped(2.0), <&Wrapped>::from(&t)); + assert_eq!(Wrapped(1), t.into()); } #[derive(Debug, Into)] @@ -1423,18 +1426,18 @@ mod with_fields { #[test] fn named() { - let mut foo = Struct { + let mut s = Struct { a: Wrapped(1), b: Wrapped(2.0), c: Wrapped(3.0), }; - assert_eq!(&Transmuted(1), <&Transmuted>::from(&foo)); - assert_eq!(&mut Transmuted(3.0), <&mut Transmuted>::from(&mut foo)); - assert_eq!(&mut Wrapped(3.0), <&mut Wrapped>::from(&mut foo)); - assert_eq!((&Wrapped(1), &Transmuted(3.0)), (&foo).into()); - assert_eq!(&Wrapped(2.0), <&Wrapped>::from(&foo)); - assert_eq!(Wrapped(1), foo.into()); + assert_eq!(&Transmuted(1), <&Transmuted>::from(&s)); + assert_eq!(&mut Transmuted(3.0), <&mut Transmuted>::from(&mut s)); + assert_eq!(&mut Wrapped(3.0), <&mut Wrapped>::from(&mut s)); + assert_eq!((&Wrapped(1), &Transmuted(3.0)), (&s).into()); + assert_eq!(&Wrapped(2.0), <&Wrapped>::from(&s)); + assert_eq!(Wrapped(1), s.into()); } mod separate { @@ -1458,21 +1461,18 @@ mod with_fields { #[test] fn tuple() { - let mut foo = Tuple(Wrapped(1), Wrapped(2.0)); - - assert_eq!((&Wrapped(1), &Wrapped(2.0)), (&foo).into()); - assert_eq!((Wrapped(1), Wrapped(2.0)), foo.into()); - assert_eq!((Wrapped(1), Transmuted(2.0)), foo.into()); - assert_eq!((&mut Wrapped(1), &mut Transmuted(2.0)), (&mut foo).into()); - assert_eq!(&Wrapped(1), <&Wrapped>::from(&foo)); - assert_eq!(&Transmuted(1), <&Transmuted>::from(&foo)); - assert_eq!(Wrapped(1), >::from(foo)); - assert_eq!(&mut Wrapped(2.0), <&mut Wrapped>::from(&mut foo)); - assert_eq!( - &mut Transmuted(2.0), - <&mut Transmuted>::from(&mut foo), - ); - assert_eq!(Wrapped(2.0), >::from(foo)); + let mut t = Tuple(Wrapped(1), Wrapped(2.0)); + + assert_eq!((&Wrapped(1), &Wrapped(2.0)), (&t).into()); + assert_eq!((Wrapped(1), Wrapped(2.0)), t.into()); + assert_eq!((Wrapped(1), Transmuted(2.0)), t.into()); + assert_eq!((&mut Wrapped(1), &mut Transmuted(2.0)), (&mut t).into()); + assert_eq!(&Wrapped(1), <&Wrapped>::from(&t)); + assert_eq!(&Transmuted(1), <&Transmuted>::from(&t)); + assert_eq!(Wrapped(1), >::from(t)); + assert_eq!(&mut Wrapped(2.0), <&mut Wrapped>::from(&mut t)); + assert_eq!(&mut Transmuted(2.0), <&mut Transmuted>::from(&mut t)); + assert_eq!(Wrapped(2.0), >::from(t)); } #[derive(Clone, Copy, Debug, Into)] @@ -1493,24 +1493,21 @@ mod with_fields { #[test] fn named() { - let mut foo = Struct { + let mut s = Struct { a: Wrapped(1), b: Wrapped(2.0), }; - assert_eq!((&Wrapped(1), &Wrapped(2.0)), (&foo).into()); - assert_eq!((Wrapped(1), Wrapped(2.0)), foo.into()); - assert_eq!((Wrapped(1), Transmuted(2.0)), foo.into()); - assert_eq!((&mut Wrapped(1), &mut Transmuted(2.0)), (&mut foo).into()); - assert_eq!(&Wrapped(1), <&Wrapped>::from(&foo)); - assert_eq!(&Transmuted(1), <&Transmuted>::from(&foo)); - assert_eq!(Wrapped(1), >::from(foo)); - assert_eq!(&mut Wrapped(2.0), <&mut Wrapped>::from(&mut foo)); - assert_eq!( - &mut Transmuted(2.0), - <&mut Transmuted>::from(&mut foo), - ); - assert_eq!(Wrapped(2.0), >::from(foo)); + assert_eq!((&Wrapped(1), &Wrapped(2.0)), (&s).into()); + assert_eq!((Wrapped(1), Wrapped(2.0)), s.into()); + assert_eq!((Wrapped(1), Transmuted(2.0)), s.into()); + assert_eq!((&mut Wrapped(1), &mut Transmuted(2.0)), (&mut s).into()); + assert_eq!(&Wrapped(1), <&Wrapped>::from(&s)); + assert_eq!(&Transmuted(1), <&Transmuted>::from(&s)); + assert_eq!(Wrapped(1), >::from(s)); + assert_eq!(&mut Wrapped(2.0), <&mut Wrapped>::from(&mut s)); + assert_eq!(&mut Transmuted(2.0), <&mut Transmuted>::from(&mut s),); + assert_eq!(Wrapped(2.0), >::from(s)); } } } diff --git a/tests/into_iterator.rs b/tests/into_iterator.rs index 7a876c96..755567c7 100644 --- a/tests/into_iterator.rs +++ b/tests/into_iterator.rs @@ -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"))] #[macro_use] diff --git a/tests/is_variant.rs b/tests/is_variant.rs index 9fdc0971..62ce2c83 100644 --- a/tests/is_variant.rs +++ b/tests/is_variant.rs @@ -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::IsVariant; diff --git a/tests/mul.rs b/tests/mul.rs index 706c3ec3..6e8ad745 100644 --- a/tests/mul.rs +++ b/tests/mul.rs @@ -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::Mul; diff --git a/tests/mul_assign.rs b/tests/mul_assign.rs index 51087ac6..ae9221b7 100644 --- a/tests/mul_assign.rs +++ b/tests/mul_assign.rs @@ -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 core::marker::PhantomData; diff --git a/tests/no_std.rs b/tests/no_std.rs index 3b5cdb2d..7d2adf14 100644 --- a/tests/no_std.rs +++ b/tests/no_std.rs @@ -1,5 +1,5 @@ #![no_std] -#![allow(dead_code)] +#![allow(dead_code)] // some code is tested for type checking only use derive_more::{ Add, AddAssign, Constructor, Deref, DerefMut, Display, From, FromStr, Index, diff --git a/tests/not.rs b/tests/not.rs index bb340fac..96b4bb3a 100644 --- a/tests/not.rs +++ b/tests/not.rs @@ -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::Not; diff --git a/tests/try_from.rs b/tests/try_from.rs index a44cdd07..854533f3 100644 --- a/tests/try_from.rs +++ b/tests/try_from.rs @@ -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::TryFrom; @@ -56,6 +56,7 @@ fn enum_with_complex_repr() { assert!(Enum::try_from(-1).is_err()); } +#[cfg(not(msrv))] // TODO: Remove once MSRV bumps 1.66 or higher. #[test] fn test_discriminants_on_enum_with_fields() { #[derive(TryFrom, Clone, Copy, Debug, Eq, PartialEq)] diff --git a/tests/try_into.rs b/tests/try_into.rs index 55ebf52d..37485eff 100644 --- a/tests/try_into.rs +++ b/tests/try_into.rs @@ -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; diff --git a/tests/try_unwrap.rs b/tests/try_unwrap.rs index 294e5d40..e8a2dd8b 100644 --- a/tests/try_unwrap.rs +++ b/tests/try_unwrap.rs @@ -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; diff --git a/tests/unwrap.rs b/tests/unwrap.rs index f8e760b9..ebff8667 100644 --- a/tests/unwrap.rs +++ b/tests/unwrap.rs @@ -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::Unwrap;