Skip to content

Commit 6a2a56d

Browse files
authored
Rollup merge of #98233 - RalfJung:ref-alloc, r=thomcc
Remove accidental uses of `&A: Allocator` Cc #98232 Fixes #98176 (for real this time)
2 parents cf3245e + b05d71f commit 6a2a56d

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

library/alloc/src/collections/btree/map.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1644,11 +1644,11 @@ impl<K, V, A: Allocator + Clone> IntoIter<K, V, A> {
16441644
&mut self,
16451645
) -> Option<Handle<NodeRef<marker::Dying, K, V, marker::LeafOrInternal>, marker::KV>> {
16461646
if self.length == 0 {
1647-
self.range.deallocating_end(&self.alloc);
1647+
self.range.deallocating_end(self.alloc.clone());
16481648
None
16491649
} else {
16501650
self.length -= 1;
1651-
Some(unsafe { self.range.deallocating_next_unchecked(&self.alloc) })
1651+
Some(unsafe { self.range.deallocating_next_unchecked(self.alloc.clone()) })
16521652
}
16531653
}
16541654

@@ -1658,11 +1658,11 @@ impl<K, V, A: Allocator + Clone> IntoIter<K, V, A> {
16581658
&mut self,
16591659
) -> Option<Handle<NodeRef<marker::Dying, K, V, marker::LeafOrInternal>, marker::KV>> {
16601660
if self.length == 0 {
1661-
self.range.deallocating_end(&self.alloc);
1661+
self.range.deallocating_end(self.alloc.clone());
16621662
None
16631663
} else {
16641664
self.length -= 1;
1665-
Some(unsafe { self.range.deallocating_next_back_unchecked(&self.alloc) })
1665+
Some(unsafe { self.range.deallocating_next_back_unchecked(self.alloc.clone()) })
16661666
}
16671667
}
16681668
}
@@ -1849,7 +1849,7 @@ where
18491849
type Item = (K, V);
18501850

18511851
fn next(&mut self) -> Option<(K, V)> {
1852-
self.inner.next(&mut self.pred, &self.alloc)
1852+
self.inner.next(&mut self.pred, self.alloc.clone())
18531853
}
18541854

18551855
fn size_hint(&self) -> (usize, Option<usize>) {

library/alloc/src/collections/btree/set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ where
13201320
fn next(&mut self) -> Option<T> {
13211321
let pred = &mut self.pred;
13221322
let mut mapped_pred = |k: &T, _v: &mut ()| pred(k);
1323-
self.inner.next(&mut mapped_pred, &self.alloc).map(|(k, _)| k)
1323+
self.inner.next(&mut mapped_pred, self.alloc.clone()).map(|(k, _)| k)
13241324
}
13251325

13261326
fn size_hint(&self) -> (usize, Option<usize>) {

library/std/src/alloc.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ impl System {
187187
old_size => unsafe {
188188
let new_ptr = self.alloc_impl(new_layout, zeroed)?;
189189
ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_mut_ptr(), old_size);
190-
Allocator::deallocate(&self, ptr, old_layout);
190+
Allocator::deallocate(self, ptr, old_layout);
191191
Ok(new_ptr)
192192
},
193193
}
@@ -254,7 +254,7 @@ unsafe impl Allocator for System {
254254
match new_layout.size() {
255255
// SAFETY: conditions must be upheld by the caller
256256
0 => unsafe {
257-
Allocator::deallocate(&self, ptr, old_layout);
257+
Allocator::deallocate(self, ptr, old_layout);
258258
Ok(NonNull::slice_from_raw_parts(new_layout.dangling(), 0))
259259
},
260260

@@ -274,9 +274,9 @@ unsafe impl Allocator for System {
274274
// `new_ptr`. Thus, the call to `copy_nonoverlapping` is safe. The safety contract
275275
// for `dealloc` must be upheld by the caller.
276276
new_size => unsafe {
277-
let new_ptr = Allocator::allocate(&self, new_layout)?;
277+
let new_ptr = Allocator::allocate(self, new_layout)?;
278278
ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_mut_ptr(), new_size);
279-
Allocator::deallocate(&self, ptr, old_layout);
279+
Allocator::deallocate(self, ptr, old_layout);
280280
Ok(new_ptr)
281281
},
282282
}

0 commit comments

Comments
 (0)