From 6f8e2e4cbaa06a3794d6f78a6e5b600a8c1b1006 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Tue, 2 Jan 2024 21:37:50 -0800 Subject: [PATCH 1/2] Loosen the generic bound on `impl IntoIterator for &SymbolTable` All of these existing `IntoIterator` impls did not include the generic parameter for the `BuildHasher`, meaning the impl was overly (and unnecessarily) restrictive. Found by `clippy::iter_without_into_iter`. See https://github.com/rust-lang/rust-clippy/issues/11692#issuecomment-1874872833. --- src/bytes.rs | 2 +- src/cstr.rs | 2 +- src/osstr.rs | 2 +- src/path.rs | 2 +- src/str.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bytes.rs b/src/bytes.rs index 63412fc5..22bb6164 100644 --- a/src/bytes.rs +++ b/src/bytes.rs @@ -268,7 +268,7 @@ impl<'a> Iterator for Iter<'a> { impl<'a> FusedIterator for Iter<'a> {} -impl<'a> IntoIterator for &'a SymbolTable { +impl<'a, S> IntoIterator for &'a SymbolTable { type Item = (Symbol, &'a [u8]); type IntoIter = Iter<'a>; diff --git a/src/cstr.rs b/src/cstr.rs index f77cf8ad..ec9704b3 100644 --- a/src/cstr.rs +++ b/src/cstr.rs @@ -277,7 +277,7 @@ impl<'a> Iterator for Iter<'a> { impl<'a> FusedIterator for Iter<'a> {} -impl<'a> IntoIterator for &'a SymbolTable { +impl<'a, S> IntoIterator for &'a SymbolTable { type Item = (Symbol, &'a CStr); type IntoIter = Iter<'a>; diff --git a/src/osstr.rs b/src/osstr.rs index bd5795b4..7cd5cc35 100644 --- a/src/osstr.rs +++ b/src/osstr.rs @@ -277,7 +277,7 @@ impl<'a> Iterator for Iter<'a> { impl<'a> FusedIterator for Iter<'a> {} -impl<'a> IntoIterator for &'a SymbolTable { +impl<'a, S> IntoIterator for &'a SymbolTable { type Item = (Symbol, &'a OsStr); type IntoIter = Iter<'a>; diff --git a/src/path.rs b/src/path.rs index 8f3ed1c3..9487a8a1 100644 --- a/src/path.rs +++ b/src/path.rs @@ -277,7 +277,7 @@ impl<'a> Iterator for Iter<'a> { impl<'a> FusedIterator for Iter<'a> {} -impl<'a> IntoIterator for &'a SymbolTable { +impl<'a, S> IntoIterator for &'a SymbolTable { type Item = (Symbol, &'a Path); type IntoIter = Iter<'a>; diff --git a/src/str.rs b/src/str.rs index 902eee26..17ae598d 100644 --- a/src/str.rs +++ b/src/str.rs @@ -214,7 +214,7 @@ impl<'a> Iterator for Iter<'a> { impl<'a> FusedIterator for Iter<'a> {} -impl<'a> IntoIterator for &'a SymbolTable { +impl<'a, S> IntoIterator for &'a SymbolTable { type Item = (Symbol, &'a str); type IntoIter = Iter<'a>; From a35f782839d1270c372aea1f50ec398655556578 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Tue, 2 Jan 2024 21:39:32 -0800 Subject: [PATCH 2/2] Fix use of unnecessarily fallible conversion Fixes `clippy::unnecessary_fallible_conversions`. This is probably a holdover from before that cfg block was in there. --- src/convert.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/convert.rs b/src/convert.rs index 12c1bf1c..b14dba5e 100644 --- a/src/convert.rs +++ b/src/convert.rs @@ -254,7 +254,7 @@ mod tests { #[cfg(target_pointer_width = "64")] { Symbol::try_from(usize::MAX).unwrap_err(); - Symbol::try_from(u64::try_from(u32::MAX).unwrap() + 1).unwrap_err(); + Symbol::try_from(u64::from(u32::MAX) + 1).unwrap_err(); } } @@ -281,7 +281,7 @@ mod tests { #[cfg(target_pointer_width = "64")] { Symbol::try_from(&usize::MAX).unwrap_err(); - Symbol::try_from(&(u64::try_from(u32::MAX).unwrap() + 1)).unwrap_err(); + Symbol::try_from(&(u64::from(u32::MAX) + 1)).unwrap_err(); } }