diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index abd5f17137ec2..2a3144585f228 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -1543,11 +1543,17 @@ impl<'a, K: 'a, V: 'a> Iterator for Iter<'a, K, V> { self.next_back() } - fn min(mut self) -> Option<(&'a K, &'a V)> { + fn min(mut self) -> Option<(&'a K, &'a V)> + where + (&'a K, &'a V): Ord, + { self.next() } - fn max(mut self) -> Option<(&'a K, &'a V)> { + fn max(mut self) -> Option<(&'a K, &'a V)> + where + (&'a K, &'a V): Ord, + { self.next_back() } } @@ -1612,11 +1618,17 @@ impl<'a, K, V> Iterator for IterMut<'a, K, V> { self.next_back() } - fn min(mut self) -> Option<(&'a K, &'a mut V)> { + fn min(mut self) -> Option<(&'a K, &'a mut V)> + where + (&'a K, &'a mut V): Ord, + { self.next() } - fn max(mut self) -> Option<(&'a K, &'a mut V)> { + fn max(mut self) -> Option<(&'a K, &'a mut V)> + where + (&'a K, &'a mut V): Ord, + { self.next_back() } } @@ -1779,11 +1791,17 @@ impl<'a, K, V> Iterator for Keys<'a, K, V> { self.next_back() } - fn min(mut self) -> Option<&'a K> { + fn min(mut self) -> Option<&'a K> + where + &'a K: Ord, + { self.next() } - fn max(mut self) -> Option<&'a K> { + fn max(mut self) -> Option<&'a K> + where + &'a K: Ord, + { self.next_back() } } @@ -2008,11 +2026,17 @@ impl<'a, K, V> Iterator for Range<'a, K, V> { self.next_back() } - fn min(mut self) -> Option<(&'a K, &'a V)> { + fn min(mut self) -> Option<(&'a K, &'a V)> + where + (&'a K, &'a V): Ord, + { self.next() } - fn max(mut self) -> Option<(&'a K, &'a V)> { + fn max(mut self) -> Option<(&'a K, &'a V)> + where + (&'a K, &'a V): Ord, + { self.next_back() } } @@ -2081,11 +2105,17 @@ impl Iterator for IntoKeys { self.next_back() } - fn min(mut self) -> Option { + fn min(mut self) -> Option + where + K: Ord, + { self.next() } - fn max(mut self) -> Option { + fn max(mut self) -> Option + where + K: Ord, + { self.next_back() } } @@ -2204,11 +2234,17 @@ impl<'a, K, V> Iterator for RangeMut<'a, K, V> { self.next_back() } - fn min(mut self) -> Option<(&'a K, &'a mut V)> { + fn min(mut self) -> Option<(&'a K, &'a mut V)> + where + (&'a K, &'a mut V): Ord, + { self.next() } - fn max(mut self) -> Option<(&'a K, &'a mut V)> { + fn max(mut self) -> Option<(&'a K, &'a mut V)> + where + (&'a K, &'a mut V): Ord, + { self.next_back() } } diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index 232a017314e5e..8d2b0e519e229 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -1501,11 +1501,17 @@ impl<'a, T> Iterator for Iter<'a, T> { self.next_back() } - fn min(mut self) -> Option<&'a T> { + fn min(mut self) -> Option<&'a T> + where + &'a T: Ord, + { self.next() } - fn max(mut self) -> Option<&'a T> { + fn max(mut self) -> Option<&'a T> + where + &'a T: Ord, + { self.next_back() } } @@ -1604,11 +1610,17 @@ impl<'a, T> Iterator for Range<'a, T> { self.next_back() } - fn min(mut self) -> Option<&'a T> { + fn min(mut self) -> Option<&'a T> + where + &'a T: Ord, + { self.next() } - fn max(mut self) -> Option<&'a T> { + fn max(mut self) -> Option<&'a T> + where + &'a T: Ord, + { self.next_back() } } diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index 8916b42eda05e..896da37f94c02 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -2815,7 +2815,7 @@ impl<'a, T: 'a + Copy, A: Allocator> Extend<&'a T> for VecDeque { } #[inline] - fn extend_one(&mut self, &elem: &T) { + fn extend_one(&mut self, &elem: &'a T) { self.push_back(elem); } diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs index 98c87b2c393ea..940558974e69b 100644 --- a/library/core/src/array/mod.rs +++ b/library/core/src/array/mod.rs @@ -248,7 +248,7 @@ where impl<'a, T, const N: usize> TryFrom<&'a [T]> for &'a [T; N] { type Error = TryFromSliceError; - fn try_from(slice: &[T]) -> Result<&[T; N], TryFromSliceError> { + fn try_from(slice: &'a [T]) -> Result<&'a [T; N], TryFromSliceError> { if slice.len() == N { let ptr = slice.as_ptr() as *const [T; N]; // SAFETY: ok because we just checked that the length fits @@ -275,7 +275,7 @@ impl<'a, T, const N: usize> TryFrom<&'a [T]> for &'a [T; N] { impl<'a, T, const N: usize> TryFrom<&'a mut [T]> for &'a mut [T; N] { type Error = TryFromSliceError; - fn try_from(slice: &mut [T]) -> Result<&mut [T; N], TryFromSliceError> { + fn try_from(slice: &'a mut [T]) -> Result<&'a mut [T; N], TryFromSliceError> { if slice.len() == N { let ptr = slice.as_mut_ptr() as *mut [T; N]; // SAFETY: ok because we just checked that the length fits diff --git a/library/core/src/iter/range.rs b/library/core/src/iter/range.rs index 37db074293d8c..0171d89812feb 100644 --- a/library/core/src/iter/range.rs +++ b/library/core/src/iter/range.rs @@ -732,12 +732,18 @@ impl Iterator for ops::Range { } #[inline] - fn min(mut self) -> Option { + fn min(mut self) -> Option + where + A: Ord, + { self.next() } #[inline] - fn max(mut self) -> Option { + fn max(mut self) -> Option + where + A: Ord, + { self.next_back() } @@ -1158,12 +1164,18 @@ impl Iterator for ops::RangeInclusive { } #[inline] - fn min(mut self) -> Option { + fn min(mut self) -> Option + where + A: Ord, + { self.next() } #[inline] - fn max(mut self) -> Option { + fn max(mut self) -> Option + where + A: Ord, + { self.next_back() } diff --git a/library/portable-simd/crates/core_simd/src/ops/deref.rs b/library/portable-simd/crates/core_simd/src/ops/deref.rs index 9883a74c92d67..302bf148bd3ef 100644 --- a/library/portable-simd/crates/core_simd/src/ops/deref.rs +++ b/library/portable-simd/crates/core_simd/src/ops/deref.rs @@ -71,7 +71,7 @@ macro_rules! deref_ops { #[inline] #[must_use = "operator returns a new vector without mutating the inputs"] - fn $call(self, rhs: &$simd) -> Self::Output { + fn $call(self, rhs: &'rhs $simd) -> Self::Output { (*self).$call(*rhs) } }