@@ -273,7 +273,10 @@ impl<B: GfxBackend> Device<B> {
273273            mem_allocator :  Mutex :: new ( mem_allocator) , 
274274            desc_allocator :  Mutex :: new ( descriptors) , 
275275            queue_group, 
276-             life_guard :  LifeGuard :: new ( Label :: new_borrowed ( "<device>" ) ) , 
276+             #[ cfg( debug_assertions) ]  
277+             life_guard :  LifeGuard :: new ( "<device>" . to_string ( ) ) , 
278+             #[ cfg( not( debug_assertions) ) ]  
279+             life_guard :  LifeGuard :: new ( String :: new ( ) ) , 
277280            active_submission_index :  0 , 
278281            trackers :  Mutex :: new ( TrackerSet :: new ( B :: VARIANT ) ) , 
279282            render_passes :  Mutex :: new ( FastHashMap :: default ( ) ) , 
@@ -467,7 +470,7 @@ impl<B: GfxBackend> Device<B> {
467470                _ => panic ! ( "failed to create buffer: {}" ,  err) , 
468471            } , 
469472        ) ?; 
470-         if  let  Some ( ref  label)  = desc. label . borrow ( )  { 
473+         if  let  Some ( ref  label)  = desc. label  { 
471474            unsafe  {  self . raw . set_buffer_name ( & mut  buffer,  label)  } ; 
472475        } 
473476
@@ -489,7 +492,7 @@ impl<B: GfxBackend> Device<B> {
489492            full_range :  ( ) , 
490493            sync_mapped_writes :  None , 
491494            map_state :  resource:: BufferMapState :: Idle , 
492-             life_guard :  LifeGuard :: new ( desc. label . as_static ( ) ) , 
495+             life_guard :  LifeGuard :: new ( desc. label . to_string_or_default ( ) ) , 
493496        } ) 
494497    } 
495498
@@ -552,7 +555,7 @@ impl<B: GfxBackend> Device<B> {
552555                    hal:: image:: CreationError :: OutOfMemory ( _)  => DeviceError :: OutOfMemory , 
553556                    _ => panic ! ( "failed to create texture: {}" ,  err) , 
554557                } ) ?; 
555-             if  let  Some ( ref  label)  = desc. label . borrow ( )  { 
558+             if  let  Some ( ref  label)  = desc. label  { 
556559                self . raw . set_image_name ( & mut  image,  label) ; 
557560            } 
558561            image
@@ -581,7 +584,7 @@ impl<B: GfxBackend> Device<B> {
581584                levels :  0 ..desc. mip_level_count  as  hal:: image:: Level , 
582585                layers :  0 ..kind. num_layers ( ) , 
583586            } , 
584-             life_guard :  LifeGuard :: new ( desc. label . as_static ( ) ) , 
587+             life_guard :  LifeGuard :: new ( desc. label . to_string_or_default ( ) ) , 
585588        } ) 
586589    } 
587590
@@ -811,7 +814,7 @@ impl<B: GfxBackend> Device<B> {
811814                . raw 
812815                . create_pipeline_layout ( descriptor_set_layouts,  push_constants) 
813816                . or ( Err ( DeviceError :: OutOfMemory ) ) ?; 
814-             if  let  Some ( _)  = desc. label . borrow ( )  { 
817+             if  let  Some ( _)  = desc. label  { 
815818                //TODO-0.6: needs gfx changes published 
816819                //self.raw.set_pipeline_layout_name(&mut raw_layout, label); 
817820            } 
@@ -824,7 +827,7 @@ impl<B: GfxBackend> Device<B> {
824827                value :  id:: Valid ( self_id) , 
825828                ref_count :  self . life_guard . add_ref ( ) , 
826829            } , 
827-             life_guard :  LifeGuard :: new ( desc. label . as_static ( ) ) , 
830+             life_guard :  LifeGuard :: new ( desc. label . to_string_or_default ( ) ) , 
828831            bind_group_layout_ids :  desc
829832                . bind_group_layouts 
830833                . iter ( ) 
@@ -1597,7 +1600,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
15971600            extent :  texture. kind . extent ( ) . at_level ( desc. base_mip_level  as  _ ) , 
15981601            samples :  texture. kind . num_samples ( ) , 
15991602            selector, 
1600-             life_guard :  LifeGuard :: new ( desc. label . as_static ( ) ) , 
1603+             life_guard :  LifeGuard :: new ( desc. label . to_string_or_default ( ) ) , 
16011604        } ; 
16021605        let  ref_count = view. life_guard . add_ref ( ) ; 
16031606
@@ -1759,7 +1762,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
17591762                value :  id:: Valid ( device_id) , 
17601763                ref_count :  device. life_guard . add_ref ( ) , 
17611764            } , 
1762-             life_guard :  LifeGuard :: new ( desc. label . as_static ( ) ) , 
1765+             life_guard :  LifeGuard :: new ( desc. label . to_string_or_default ( ) ) , 
17631766            comparison :  info. comparison . is_some ( ) , 
17641767        } ; 
17651768        let  ref_count = sampler. life_guard . add_ref ( ) ; 
@@ -1858,7 +1861,11 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
18581861            } 
18591862        } 
18601863
1861-         let  layout = device. create_bind_group_layout ( device_id,  desc. label . borrow ( ) ,  entry_map) ?; 
1864+         let  layout = device. create_bind_group_layout ( 
1865+             device_id, 
1866+             desc. label . as_ref ( ) . map ( |cow| cow. as_ref ( ) ) , 
1867+             entry_map, 
1868+         ) ?; 
18621869
18631870        let  id = hub
18641871            . bind_group_layouts 
@@ -2426,7 +2433,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
24262433                ref_count :  device. life_guard . add_ref ( ) , 
24272434            } , 
24282435            layout_id :  id:: Valid ( desc. layout ) , 
2429-             life_guard :  LifeGuard :: new ( desc. label . as_static ( ) ) , 
2436+             life_guard :  LifeGuard :: new ( desc. label . to_string_or_default ( ) ) , 
24302437            used, 
24312438            dynamic_binding_info, 
24322439        } ; 
@@ -3202,7 +3209,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
32023209            flags, 
32033210            index_format :  desc. vertex_state . index_format , 
32043211            vertex_strides, 
3205-             life_guard :  LifeGuard :: new ( desc. label . as_static ( ) ) , 
3212+             life_guard :  LifeGuard :: new ( desc. label . to_string_or_default ( ) ) , 
32063213        } ; 
32073214
32083215        let  id = hub
@@ -3426,7 +3433,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
34263433                value :  id:: Valid ( device_id) , 
34273434                ref_count :  device. life_guard . add_ref ( ) , 
34283435            } , 
3429-             life_guard :  LifeGuard :: new ( desc. label . as_static ( ) ) , 
3436+             life_guard :  LifeGuard :: new ( desc. label . to_string_or_default ( ) ) , 
34303437        } ; 
34313438        let  id = hub
34323439            . compute_pipelines 
@@ -3631,7 +3638,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
36313638        } 
36323639
36333640        let  swap_chain = swap_chain:: SwapChain  { 
3634-             life_guard :  LifeGuard :: new ( Label :: new_borrowed ( "<SwapChain>" ) ) , 
3641+             #[ cfg( debug_assertions) ]  
3642+             life_guard :  LifeGuard :: new ( "<SwapChain>" . to_string ( ) ) , 
3643+             #[ cfg( not( debug_assertions) ) ]  
3644+             life_guard :  LifeGuard :: new ( String :: new ( ) ) , 
36353645            device_id :  Stored  { 
36363646                value :  id:: Valid ( device_id) , 
36373647                ref_count :  device. life_guard . add_ref ( ) , 
0 commit comments