Skip to content

Commit 196ca9d

Browse files
authored
Rollup merge of rust-lang#67155 - kraai:move-instead-of-binding-to-reference, r=cramertj
Move `Layout`s instead of binding by reference
2 parents c2702e3 + 4ea7bb8 commit 196ca9d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/libcore/alloc.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1142,9 +1142,9 @@ pub unsafe trait Alloc {
11421142
where Self: Sized
11431143
{
11441144
match Layout::array::<T>(n) {
1145-
Ok(ref layout) if layout.size() > 0 => {
1145+
Ok(layout) if layout.size() > 0 => {
11461146
unsafe {
1147-
self.alloc(layout.clone()).map(|p| p.cast())
1147+
self.alloc(layout).map(|p| p.cast())
11481148
}
11491149
}
11501150
_ => Err(AllocErr),
@@ -1192,9 +1192,9 @@ pub unsafe trait Alloc {
11921192
where Self: Sized
11931193
{
11941194
match (Layout::array::<T>(n_old), Layout::array::<T>(n_new)) {
1195-
(Ok(ref k_old), Ok(ref k_new)) if k_old.size() > 0 && k_new.size() > 0 => {
1195+
(Ok(k_old), Ok(k_new)) if k_old.size() > 0 && k_new.size() > 0 => {
11961196
debug_assert!(k_old.align() == k_new.align());
1197-
self.realloc(ptr.cast(), k_old.clone(), k_new.size()).map(NonNull::cast)
1197+
self.realloc(ptr.cast(), k_old, k_new.size()).map(NonNull::cast)
11981198
}
11991199
_ => {
12001200
Err(AllocErr)
@@ -1226,8 +1226,8 @@ pub unsafe trait Alloc {
12261226
where Self: Sized
12271227
{
12281228
match Layout::array::<T>(n) {
1229-
Ok(ref k) if k.size() > 0 => {
1230-
Ok(self.dealloc(ptr.cast(), k.clone()))
1229+
Ok(k) if k.size() > 0 => {
1230+
Ok(self.dealloc(ptr.cast(), k))
12311231
}
12321232
_ => {
12331233
Err(AllocErr)

0 commit comments

Comments
 (0)