@@ -258,12 +258,12 @@ mod interner {
258
258
///
259
259
/// This operation cannot fails since the only way to have a [Symbol] is to have
260
260
/// [interned](Interner::intern) the corresponding string first.
261
- pub ( crate ) fn lookup ( & self , sym : Symbol ) -> & str {
261
+ pub ( crate ) fn lookup < ' slf > ( & ' slf self , sym : Symbol ) -> & ' slf str {
262
262
// SAFETY: We are making the returned &str lifetime the same as our struct,
263
263
// which is okay here since the InnerInterner uses a typed_arena which prevents
264
264
// deallocations, so the reference will be valid while the InnerInterner exists,
265
265
// hence while the struct exists.
266
- unsafe { std:: mem:: transmute ( self . 0 . read ( ) . unwrap ( ) . lookup ( sym) ) }
266
+ unsafe { std:: mem:: transmute :: < & ' _ str , & ' slf str > ( self . 0 . read ( ) . unwrap ( ) . lookup ( sym) ) }
267
267
}
268
268
}
269
269
@@ -300,8 +300,11 @@ mod interner {
300
300
// It is also okay to use it from inside the mutex, since typed_arena does not allow
301
301
// deallocation, so references are valid until the arena drop, which is tied to the
302
302
// struct drop.
303
+ // XXX: we have to use &'a str here, not &'self str like the comment indicates. what's going on?
303
304
let in_string = unsafe {
304
- std:: mem:: transmute ( self . arena . lock ( ) . unwrap ( ) . alloc_str ( string. as_ref ( ) ) )
305
+ std:: mem:: transmute :: < & ' _ str , & ' a str > (
306
+ self . arena . lock ( ) . unwrap ( ) . alloc_str ( string. as_ref ( ) ) ,
307
+ )
305
308
} ;
306
309
let sym = Symbol ( self . vec . len ( ) as u32 ) ;
307
310
self . vec . push ( in_string) ;
@@ -312,7 +315,7 @@ mod interner {
312
315
///
313
316
/// This operation cannot fails since the only way to have a [Symbol]
314
317
/// is to have [interned](InnerInterner::intern) the corresponding string first.
315
- fn lookup ( & self , sym : Symbol ) -> & str {
318
+ fn lookup < ' slf > ( & ' slf self , sym : Symbol ) -> & ' slf str {
316
319
self . vec [ sym. 0 as usize ]
317
320
}
318
321
}
0 commit comments