Skip to content

Commit dcb8104

Browse files
committed
Auto merge of #113224 - zachs18:vec_extend_remove_allocator_lifetime, r=cuviper
Remove lifetime bound for A for `impl Extend<&'a T> for Vec<T, A>`. The lifetime of the references being copied from is unrelated to the allocator. Compare with [`impl<'a, T: 'a + Copy, A: Allocator> Extend<&'a T> for VecDeque<T, A>`](https://doc.rust-lang.org/alloc/collections/vec_deque/struct.VecDeque.html#impl-Extend%3C%26'a+T%3E-for-VecDeque%3CT,+A%3E) which does not have the `A: 'a` bound already. Since `Allocator` is unstable, the only possible `A` on stable is `Global`, and `Global: 'static`, so this change is not (should not be) observable on stable (or without `#![feature(allocator_api)]`). [This is observable on nightly](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=8c4aa166c6116a90593d2934d30cfeb3).
2 parents e0922fb + 0699345 commit dcb8104

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

library/alloc/src/vec/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2961,7 +2961,7 @@ impl<T, A: Allocator> Vec<T, A> {
29612961
/// [`copy_from_slice`]: slice::copy_from_slice
29622962
#[cfg(not(no_global_oom_handling))]
29632963
#[stable(feature = "extend_ref", since = "1.2.0")]
2964-
impl<'a, T: Copy + 'a, A: Allocator + 'a> Extend<&'a T> for Vec<T, A> {
2964+
impl<'a, T: Copy + 'a, A: Allocator> Extend<&'a T> for Vec<T, A> {
29652965
fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I) {
29662966
self.spec_extend(iter.into_iter())
29672967
}

library/alloc/src/vec/spec_extend.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<T, A: Allocator> SpecExtend<T, IntoIter<T>> for Vec<T, A> {
3636
}
3737
}
3838

39-
impl<'a, T: 'a, I, A: Allocator + 'a> SpecExtend<&'a T, I> for Vec<T, A>
39+
impl<'a, T: 'a, I, A: Allocator> SpecExtend<&'a T, I> for Vec<T, A>
4040
where
4141
I: Iterator<Item = &'a T>,
4242
T: Clone,
@@ -46,7 +46,7 @@ where
4646
}
4747
}
4848

49-
impl<'a, T: 'a, A: Allocator + 'a> SpecExtend<&'a T, slice::Iter<'a, T>> for Vec<T, A>
49+
impl<'a, T: 'a, A: Allocator> SpecExtend<&'a T, slice::Iter<'a, T>> for Vec<T, A>
5050
where
5151
T: Copy,
5252
{

0 commit comments

Comments
 (0)