@@ -8,6 +8,7 @@ pub use visualizer::AllocatorVisualizer;
8
8
use super :: allocator;
9
9
use super :: allocator:: AllocationType ;
10
10
use ash:: vk;
11
+ use core:: marker:: PhantomData ;
11
12
use log:: { debug, Level } ;
12
13
use std:: fmt;
13
14
@@ -177,7 +178,10 @@ impl Allocation {
177
178
/// See the note about safety in [the documentation of Allocation][Allocation#safety]
178
179
///
179
180
/// [`Slab`]: presser::Slab
180
- pub fn try_as_mapped_slab ( & mut self ) -> Option < MappedAllocationSlab < ' _ > > {
181
+ // best to be explicit where the lifetime is coming from since we're doing unsafe things
182
+ // and relying on an inferred liftime type in the PhantomData below
183
+ #[ allow( clippy:: needless_lifetimes) ]
184
+ pub fn try_as_mapped_slab < ' a > ( & ' a mut self ) -> Option < MappedAllocationSlab < ' a > > {
181
185
let mapped_ptr = self . mapped_ptr ( ) ?. cast ( ) . as_ptr ( ) ;
182
186
183
187
if self . size > isize:: MAX as _ {
@@ -188,7 +192,7 @@ impl Allocation {
188
192
let size = self . size as usize ;
189
193
190
194
Some ( MappedAllocationSlab {
191
- _borrowed_alloc : self ,
195
+ _borrowed_alloc : PhantomData ,
192
196
mapped_ptr,
193
197
size,
194
198
} )
@@ -273,7 +277,7 @@ impl Default for Allocation {
273
277
///
274
278
/// This type should be acquired by calling [`Allocation::try_as_mapped_slab`].
275
279
pub struct MappedAllocationSlab < ' a > {
276
- _borrowed_alloc : & ' a mut Allocation ,
280
+ _borrowed_alloc : PhantomData < & ' a mut Allocation > ,
277
281
mapped_ptr : * mut u8 ,
278
282
size : usize ,
279
283
}
@@ -298,13 +302,15 @@ unsafe impl presser::Slab for Allocation {
298
302
fn base_ptr ( & self ) -> * const u8 {
299
303
self . mapped_ptr
300
304
. expect ( "tried to use a non-mapped Allocation as a Slab" )
305
+ . 0
301
306
. as_ptr ( )
302
307
. cast ( )
303
308
}
304
309
305
310
fn base_ptr_mut ( & mut self ) -> * mut u8 {
306
311
self . mapped_ptr
307
312
. expect ( "tried to use a non-mapped Allocation as a Slab" )
313
+ . 0
308
314
. as_ptr ( )
309
315
. cast ( )
310
316
}
0 commit comments