@@ -133,7 +133,7 @@ pub struct System;
133133
134134impl System {
135135 #[ inline]
136- fn alloc_impl ( & mut self , layout : Layout , zeroed : bool ) -> Result < NonNull < [ u8 ] > , AllocErr > {
136+ fn alloc_impl ( & self , layout : Layout , zeroed : bool ) -> Result < NonNull < [ u8 ] > , AllocErr > {
137137 match layout. size ( ) {
138138 0 => Ok ( NonNull :: slice_from_raw_parts ( layout. dangling ( ) , 0 ) ) ,
139139 // SAFETY: `layout` is non-zero in size,
@@ -152,7 +152,7 @@ impl System {
152152 // SAFETY: Same as `AllocRef::grow`
153153 #[ inline]
154154 unsafe fn grow_impl (
155- & mut self ,
155+ & self ,
156156 ptr : NonNull < u8 > ,
157157 old_layout : Layout ,
158158 new_layout : Layout ,
@@ -190,7 +190,7 @@ impl System {
190190 old_size => unsafe {
191191 let new_ptr = self . alloc_impl ( new_layout, zeroed) ?;
192192 ptr:: copy_nonoverlapping ( ptr. as_ptr ( ) , new_ptr. as_mut_ptr ( ) , old_size) ;
193- self . dealloc ( ptr, old_layout) ;
193+ AllocRef :: dealloc ( & self , ptr, old_layout) ;
194194 Ok ( new_ptr)
195195 } ,
196196 }
@@ -202,17 +202,17 @@ impl System {
202202#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
203203unsafe impl AllocRef for System {
204204 #[ inline]
205- fn alloc ( & mut self , layout : Layout ) -> Result < NonNull < [ u8 ] > , AllocErr > {
205+ fn alloc ( & self , layout : Layout ) -> Result < NonNull < [ u8 ] > , AllocErr > {
206206 self . alloc_impl ( layout, false )
207207 }
208208
209209 #[ inline]
210- fn alloc_zeroed ( & mut self , layout : Layout ) -> Result < NonNull < [ u8 ] > , AllocErr > {
210+ fn alloc_zeroed ( & self , layout : Layout ) -> Result < NonNull < [ u8 ] > , AllocErr > {
211211 self . alloc_impl ( layout, true )
212212 }
213213
214214 #[ inline]
215- unsafe fn dealloc ( & mut self , ptr : NonNull < u8 > , layout : Layout ) {
215+ unsafe fn dealloc ( & self , ptr : NonNull < u8 > , layout : Layout ) {
216216 if layout. size ( ) != 0 {
217217 // SAFETY: `layout` is non-zero in size,
218218 // other conditions must be upheld by the caller
@@ -222,7 +222,7 @@ unsafe impl AllocRef for System {
222222
223223 #[ inline]
224224 unsafe fn grow (
225- & mut self ,
225+ & self ,
226226 ptr : NonNull < u8 > ,
227227 old_layout : Layout ,
228228 new_layout : Layout ,
@@ -233,7 +233,7 @@ unsafe impl AllocRef for System {
233233
234234 #[ inline]
235235 unsafe fn grow_zeroed (
236- & mut self ,
236+ & self ,
237237 ptr : NonNull < u8 > ,
238238 old_layout : Layout ,
239239 new_layout : Layout ,
@@ -244,7 +244,7 @@ unsafe impl AllocRef for System {
244244
245245 #[ inline]
246246 unsafe fn shrink (
247- & mut self ,
247+ & self ,
248248 ptr : NonNull < u8 > ,
249249 old_layout : Layout ,
250250 new_layout : Layout ,
@@ -257,7 +257,7 @@ unsafe impl AllocRef for System {
257257 match new_layout. size ( ) {
258258 // SAFETY: conditions must be upheld by the caller
259259 0 => unsafe {
260- self . dealloc ( ptr, old_layout) ;
260+ AllocRef :: dealloc ( & self , ptr, old_layout) ;
261261 Ok ( NonNull :: slice_from_raw_parts ( new_layout. dangling ( ) , 0 ) )
262262 } ,
263263
@@ -277,9 +277,9 @@ unsafe impl AllocRef for System {
277277 // `new_ptr`. Thus, the call to `copy_nonoverlapping` is safe. The safety contract
278278 // for `dealloc` must be upheld by the caller.
279279 new_size => unsafe {
280- let new_ptr = self . alloc ( new_layout) ?;
280+ let new_ptr = AllocRef :: alloc ( & self , new_layout) ?;
281281 ptr:: copy_nonoverlapping ( ptr. as_ptr ( ) , new_ptr. as_mut_ptr ( ) , new_size) ;
282- self . dealloc ( ptr, old_layout) ;
282+ AllocRef :: dealloc ( & self , ptr, old_layout) ;
283283 Ok ( new_ptr)
284284 } ,
285285 }
0 commit comments