@@ -149,7 +149,7 @@ pub trait BuildAllocRef: Sized {
149
149
/// * the alignment of the `layout` must match the alignment used to allocate that block of
150
150
/// memory
151
151
unsafe fn build_alloc_ref (
152
- & mut self ,
152
+ & self ,
153
153
ptr : NonNull < u8 > ,
154
154
layout : Option < NonZeroLayout > ,
155
155
) -> Self :: Ref ;
@@ -158,23 +158,23 @@ pub trait BuildAllocRef: Sized {
158
158
pub trait DeallocRef : Sized {
159
159
type BuildAlloc : BuildAllocRef < Ref = Self > ;
160
160
161
- fn get_build_alloc ( & mut self ) -> Self :: BuildAlloc ;
161
+ fn get_build_alloc ( & self ) -> Self :: BuildAlloc ;
162
162
163
163
/// # Safety
164
164
///
165
165
/// * `ptr` must denote a block of memory currently allocated via this allocator
166
166
/// * `layout` must *fit* that block of memory
167
167
/// * the alignment of the `layout` must match the alignment used to allocate that block of
168
168
/// memory
169
- unsafe fn dealloc ( & mut self , ptr : NonNull < u8 > , layout : NonZeroLayout ) ;
169
+ unsafe fn dealloc ( & self , ptr : NonNull < u8 > , layout : NonZeroLayout ) ;
170
170
}
171
171
172
172
pub trait AllocRef : DeallocRef {
173
173
type Error ;
174
174
175
- fn alloc ( & mut self , layout : NonZeroLayout ) -> Result < NonNull < u8 > , Self :: Error > ;
175
+ fn alloc ( & self , layout : NonZeroLayout ) -> Result < NonNull < u8 > , Self :: Error > ;
176
176
177
- fn alloc_zeroed ( & mut self , layout : NonZeroLayout ) -> Result < NonNull < u8 > , Self :: Error > {
177
+ fn alloc_zeroed ( & self , layout : NonZeroLayout ) -> Result < NonNull < u8 > , Self :: Error > {
178
178
let size = layout. size ( ) ;
179
179
let p = self . alloc ( layout) ?;
180
180
unsafe {
@@ -193,7 +193,7 @@ pub trait AllocRef: DeallocRef {
193
193
/// * `layout` must *fit* the `ptr` (see above); note the `new_size` argument need not fit it
194
194
/// * `new_size` must not be less than `layout.size()`
195
195
unsafe fn grow_in_place (
196
- & mut self ,
196
+ & self ,
197
197
ptr : NonNull < u8 > ,
198
198
layout : NonZeroLayout ,
199
199
new_size : NonZeroUsize ,
@@ -212,7 +212,7 @@ pub trait AllocRef: DeallocRef {
212
212
/// * `layout` must *fit* the `ptr` (see above); note the `new_size` argument need not fit it
213
213
/// * `new_size` must not be greater than `layout.size()` (and must be greater than zero)
214
214
unsafe fn shrink_in_place (
215
- & mut self ,
215
+ & self ,
216
216
ptr : NonNull < u8 > ,
217
217
layout : NonZeroLayout ,
218
218
new_size : NonZeroUsize ,
@@ -251,7 +251,7 @@ pub trait ReallocRef: AllocRef {
251
251
/// implement this trait atop an underlying native allocation
252
252
/// library that aborts on memory exhaustion.)
253
253
unsafe fn realloc (
254
- & mut self ,
254
+ & self ,
255
255
ptr : NonNull < u8 > ,
256
256
old_layout : NonZeroLayout ,
257
257
new_layout : NonZeroLayout ,
@@ -297,7 +297,7 @@ macro_rules! impl_buildalloc_alloc_zst {
297
297
type Ref = Self ;
298
298
299
299
unsafe fn build_alloc_ref(
300
- & mut self ,
300
+ & self ,
301
301
_ptr: NonNull <u8 >,
302
302
_layout: Option <NonZeroLayout >,
303
303
) -> Self :: Ref {
@@ -314,11 +314,11 @@ impl_buildalloc_alloc_zst!(System);
314
314
impl DeallocRef for Global {
315
315
type BuildAlloc = Self ;
316
316
317
- fn get_build_alloc ( & mut self ) -> Self :: BuildAlloc {
317
+ fn get_build_alloc ( & self ) -> Self :: BuildAlloc {
318
318
Self
319
319
}
320
320
321
- unsafe fn dealloc ( & mut self , ptr : NonNull < u8 > , layout : NonZeroLayout ) {
321
+ unsafe fn dealloc ( & self , ptr : NonNull < u8 > , layout : NonZeroLayout ) {
322
322
#[ allow( deprecated) ]
323
323
dealloc ( ptr. as_ptr ( ) , layout. into ( ) )
324
324
}
@@ -327,14 +327,14 @@ impl DeallocRef for Global {
327
327
impl AllocRef for Global {
328
328
type Error = AllocErr ;
329
329
330
- fn alloc ( & mut self , layout : NonZeroLayout ) -> Result < NonNull < u8 > , Self :: Error > {
330
+ fn alloc ( & self , layout : NonZeroLayout ) -> Result < NonNull < u8 > , Self :: Error > {
331
331
#[ allow( deprecated) ]
332
332
unsafe {
333
333
NonNull :: new ( alloc ( layout. into ( ) ) ) . ok_or ( AllocErr )
334
334
}
335
335
}
336
336
337
- fn alloc_zeroed ( & mut self , layout : NonZeroLayout ) -> Result < NonNull < u8 > , Self :: Error > {
337
+ fn alloc_zeroed ( & self , layout : NonZeroLayout ) -> Result < NonNull < u8 > , Self :: Error > {
338
338
#[ allow( deprecated) ]
339
339
unsafe {
340
340
NonNull :: new ( alloc_zeroed ( layout. into ( ) ) ) . ok_or ( AllocErr )
@@ -345,7 +345,7 @@ impl AllocRef for Global {
345
345
impl ReallocRef for Global {
346
346
// FIXME: Remove `else` branch. This is needed, as std provides old method.
347
347
unsafe fn realloc (
348
- & mut self ,
348
+ & self ,
349
349
ptr : NonNull < u8 > ,
350
350
old_layout : NonZeroLayout ,
351
351
new_layout : NonZeroLayout ,
@@ -369,11 +369,11 @@ impl ReallocRef for Global {
369
369
impl DeallocRef for System {
370
370
type BuildAlloc = Self ;
371
371
372
- fn get_build_alloc ( & mut self ) -> Self :: BuildAlloc {
372
+ fn get_build_alloc ( & self ) -> Self :: BuildAlloc {
373
373
Self
374
374
}
375
375
376
- unsafe fn dealloc ( & mut self , ptr : NonNull < u8 > , layout : NonZeroLayout ) {
376
+ unsafe fn dealloc ( & self , ptr : NonNull < u8 > , layout : NonZeroLayout ) {
377
377
GlobalAlloc :: dealloc ( self , ptr. as_ptr ( ) , layout. into ( ) )
378
378
}
379
379
}
@@ -382,11 +382,11 @@ impl DeallocRef for System {
382
382
impl AllocRef for System {
383
383
type Error = AllocErr ;
384
384
385
- fn alloc ( & mut self , layout : NonZeroLayout ) -> Result < NonNull < u8 > , Self :: Error > {
385
+ fn alloc ( & self , layout : NonZeroLayout ) -> Result < NonNull < u8 > , Self :: Error > {
386
386
unsafe { NonNull :: new ( GlobalAlloc :: alloc ( self , layout. into ( ) ) ) . ok_or ( AllocErr ) }
387
387
}
388
388
389
- fn alloc_zeroed ( & mut self , layout : NonZeroLayout ) -> Result < NonNull < u8 > , Self :: Error > {
389
+ fn alloc_zeroed ( & self , layout : NonZeroLayout ) -> Result < NonNull < u8 > , Self :: Error > {
390
390
unsafe { NonNull :: new ( GlobalAlloc :: alloc_zeroed ( self , layout. into ( ) ) ) . ok_or ( AllocErr ) }
391
391
}
392
392
}
@@ -395,7 +395,7 @@ impl AllocRef for System {
395
395
impl ReallocRef for System {
396
396
// FIXME: Remove `else` branch. This is needed, as std provides old method.
397
397
unsafe fn realloc (
398
- & mut self ,
398
+ & self ,
399
399
ptr : NonNull < u8 > ,
400
400
old_layout : NonZeroLayout ,
401
401
new_layout : NonZeroLayout ,
@@ -417,7 +417,7 @@ impl ReallocRef for System {
417
417
418
418
#[ inline]
419
419
unsafe fn alloc_copy_dealloc < A : ReallocRef > (
420
- alloc : & mut A ,
420
+ alloc : & A ,
421
421
ptr : NonNull < u8 > ,
422
422
old_layout : NonZeroLayout ,
423
423
new_layout : NonZeroLayout ,
0 commit comments