Repository: JelteF/derive_more
Pull request #385 (2024-07-05 21:36:04)

Remove unused imports for no_std tests
When running no_std tests I realised there were warnings. This removes all of
them and configures CI to complain when this happens next.



Patch:
diff --git a/impl/src/try_into.rs b/impl/src/try_into.rs
index 4647827..a2ebce8 100644
--- a/impl/src/try_into.rs
+++ b/impl/src/try_into.rs
@@ -104,7 +104,7 @@ pub fn expand(input: &DeriveInput, trait_name: &'static str) -> Result<TokenStre
             impl #impl_generics derive_more::core::convert::TryFrom<
                 #reference_with_lifetime #input_type #ty_generics
             > for (#(#reference_with_lifetime #original_types),*) #where_clause {
-                type Error = derive_more::TryIntoError<#reference_with_lifetime #input_type>;
+                type Error = derive_more::TryIntoError<#reference_with_lifetime #input_type #ty_generics>;
 
                 #[inline]
                 fn try_from(


Test patch:
diff --git a/ci/test_all_features.sh b/ci/test_all_features.sh
index 9357d57..ada63e5 100755
--- a/ci/test_all_features.sh
+++ b/ci/test_all_features.sh
@@ -8,5 +8,5 @@ fi
 set -euxo pipefail
 
 for feature in $(tomljson Cargo.toml | jq --raw-output '.features | keys[]' | grep -v 'default\|std\|full\|testing-helpers'); do
-    cargo +nightly test -p derive_more --tests --no-default-features --features "$feature$std,testing-helpers"
+    RUSTFLAGS='-D warnings' cargo +nightly test -p derive_more --tests --no-default-features --features "$feature$std,testing-helpers"
 done
diff --git a/tests/debug.rs b/tests/debug.rs
index 15e7f12..bc6b613 100644
--- a/tests/debug.rs
+++ b/tests/debug.rs
@@ -1918,7 +1918,7 @@ mod generic {
 // See: https://github.com/JelteF/derive_more/issues/301
 mod complex_enum_syntax {
     #[cfg(not(feature = "std"))]
-    use alloc::{boxed::Box, format};
+    use alloc::format;
 
     use derive_more::Debug;
 
diff --git a/tests/deref_mut.rs b/tests/deref_mut.rs
index dab6733..635f63b 100644
--- a/tests/deref_mut.rs
+++ b/tests/deref_mut.rs
@@ -5,7 +5,7 @@
 extern crate alloc;
 
 #[cfg(not(feature = "std"))]
-use alloc::{boxed::Box, format, vec, vec::Vec};
+use alloc::{boxed::Box, vec, vec::Vec};
 
 use derive_more::DerefMut;
 
diff --git a/tests/display.rs b/tests/display.rs
index 1e7ddfc..7ae52f6 100644
--- a/tests/display.rs
+++ b/tests/display.rs
@@ -5,12 +5,7 @@
 extern crate alloc;
 
 #[cfg(not(feature = "std"))]
-use alloc::{
-    boxed::Box,
-    format,
-    string::{String, ToString},
-    vec::Vec,
-};
+use alloc::{format, string::ToString};
 
 use derive_more::{
     Binary, Display, LowerExp, LowerHex, Octal, Pointer, UpperExp, UpperHex,
diff --git a/tests/generics.rs b/tests/generics.rs
index bf968eb..42c568a 100644
--- a/tests/generics.rs
+++ b/tests/generics.rs
@@ -3,7 +3,7 @@
 
 use derive_more::{
     Add, AddAssign, Constructor, Deref, DerefMut, Display, Error, From, FromStr, Index,
-    IndexMut, IntoIterator, Mul, MulAssign, Not, Sum,
+    IndexMut, IntoIterator, Mul, MulAssign, Not, Sum, TryInto,
 };
 
 #[derive(
@@ -262,3 +262,11 @@ struct StructLifetimeGenericBoundsConstDefault<
 > {
     inner: &'lt E,
 }
+
+#[derive(Debug, Display)]
+struct Wrapper<'a, const Y: usize, U>(&'a [U; Y]);
+
+#[derive(Debug, Display, TryInto)]
+enum Foo<'lt: 'static, T: Clone, const X: usize> {
+    X(Wrapper<'lt, X, T>),
+}
diff --git a/tests/try_into.rs b/tests/try_into.rs
index 37485ef..95b510e 100644
--- a/tests/try_into.rs
+++ b/tests/try_into.rs
@@ -40,6 +40,13 @@ enum MixedInts {
     Unit2,
 }
 
+#[derive(Clone, Copy, Debug, Eq, PartialEq)]
+struct Wrapper<'a, const Y: usize, U>(&'a [U; Y]);
+
+enum Foo<'lt: 'static, T: Clone, const X: usize> {
+    X(Wrapper<'lt, X, T>),
+}
+
 #[test]
 fn test_try_into() {
     let mut i = MixedInts::SmallInt(42);