@@ -589,14 +589,16 @@ impl DynamicDictionarySegment {
589589 unsafe { self . control . as_ref ( ) }
590590 }
591591
592- unsafe fn string_table_mut (
593- & self ,
594- ) -> & mut HashTable < PackedStringEntry , DynamicMappedBumpAllocator > {
595- unsafe { & mut * ( * self . control . as_ptr ( ) ) . string_table . as_mut_ptr ( ) }
592+ unsafe fn string_table_ptr (
593+ control : NonNull < DynamicDictionaryControl > ,
594+ ) -> * mut HashTable < PackedStringEntry , DynamicMappedBumpAllocator > {
595+ unsafe { ( * control. as_ptr ( ) ) . string_table . as_mut_ptr ( ) }
596596 }
597597
598- unsafe fn function_table_mut ( & self ) -> & mut HashTable < u64 , DynamicMappedBumpAllocator > {
599- unsafe { & mut * ( * self . control . as_ptr ( ) ) . function_table . as_mut_ptr ( ) }
598+ unsafe fn function_table_ptr (
599+ control : NonNull < DynamicDictionaryControl > ,
600+ ) -> * mut HashTable < u64 , DynamicMappedBumpAllocator > {
601+ unsafe { ( * control. as_ptr ( ) ) . function_table . as_mut_ptr ( ) }
600602 }
601603
602604 fn initialize_tables (
@@ -724,7 +726,7 @@ impl DynamicDictionarySegment {
724726
725727 let hash = hash_builder. hash_one ( s) ;
726728 let _guard = RawMutexGuard :: lock ( & self . control ( ) . string_mutex ) ;
727- let table = unsafe { self . string_table_mut ( ) } ;
729+ let table = unsafe { & mut * Self :: string_table_ptr ( self . control ) } ;
728730 if let Some ( found) = table. find ( hash, |entry| self . entry_matches ( * entry, s) ) {
729731 return Ok ( DynamicStringIndex {
730732 value : found. index ( ) ,
@@ -760,7 +762,7 @@ impl DynamicDictionarySegment {
760762 let key = function_lookup_key ( name. value , filename. value ) ;
761763 let hash = hash_builder. hash_one ( key) ;
762764 let _guard = RawMutexGuard :: lock ( & self . control ( ) . function_mutex ) ;
763- let table = unsafe { self . function_table_mut ( ) } ;
765+ let table = unsafe { & mut * Self :: function_table_ptr ( self . control ) } ;
764766 if let Some ( found) = table. find ( hash, |word| function_lookup_key_from_packed ( * word) == key)
765767 {
766768 return Ok ( DynamicFunctionIndex {
@@ -932,10 +934,18 @@ impl DynamicProfilesDictionary {
932934 . try_insert_function ( & self . hasher , function. name , function. filename )
933935 }
934936
937+ /// # Safety
938+ ///
939+ /// The caller must ensure `id` is valid for this dictionary and that the
940+ /// returned string is not used after the dictionary is dropped.
935941 pub unsafe fn get_str ( & self , id : DynamicStringIndex ) -> & str {
936942 unsafe { self . segment . get_string_unchecked ( id) }
937943 }
938944
945+ /// # Safety
946+ ///
947+ /// The caller must ensure `id` is valid for this dictionary and that the
948+ /// dictionary remains alive for the duration of the call.
939949 pub unsafe fn get_func ( & self , id : DynamicFunctionIndex ) -> DynamicFunction {
940950 self . segment . get_function ( id) . unwrap_or_default ( )
941951 }
@@ -1082,10 +1092,11 @@ impl std::hash::Hash for StoredStackTrace {
10821092 }
10831093}
10841094
1085- fn try_allocate_arena_slice < ' a , T : Copy > (
1086- arena : & ' a ChainAllocator < VirtualAllocator > ,
1095+ #[ allow( clippy:: mut_from_ref) ]
1096+ fn try_allocate_arena_slice < T : Copy > (
1097+ arena : & ChainAllocator < VirtualAllocator > ,
10871098 len : usize ,
1088- ) -> Result < & ' a mut [ T ] , ( ) > {
1099+ ) -> Result < & mut [ T ] , ( ) > {
10891100 if len == 0 {
10901101 return Ok ( & mut [ ] ) ;
10911102 }
@@ -1372,8 +1383,7 @@ impl DynamicLabelSetTable {
13721383 let mut cache = FxIndexMap :: default ( ) ;
13731384 cache. reserve ( 28 ) ;
13741385 cache. insert ( StoredLabelSlice ( & [ ] ) , 0 ) ;
1375- let mut entries: Vec < & ' static [ StoredLabel ] > = Vec :: new ( ) ;
1376- entries. reserve ( 28 ) ;
1386+ let mut entries: Vec < & ' static [ StoredLabel ] > = Vec :: with_capacity ( 28 ) ;
13771387 entries. push ( & [ ] as & ' static [ StoredLabel ] ) ;
13781388 Self {
13791389 arena,
@@ -1908,10 +1918,10 @@ impl DynamicProfile {
19081918 }
19091919
19101920 for label in labels {
1911- if label. key == self . well_known . local_root_span_id {
1912- if !label. str . is_empty ( ) || label. num == 0 {
1913- return Err ( DynamicProfileError :: InvalidLabelValue ) ;
1914- }
1921+ if label. key == self . well_known . local_root_span_id
1922+ && ( !label. str . is_empty ( ) || label. num == 0 )
1923+ {
1924+ return Err ( DynamicProfileError :: InvalidLabelValue ) ;
19151925 }
19161926
19171927 if label. key == self . well_known . end_timestamp_ns {
0 commit comments