From 07f102c1c302226481509749d2490e1eff70eaea Mon Sep 17 00:00:00 2001
From: Douglas Raillard <douglas.raillard@arm.com>
Date: Tue, 14 Nov 2023 11:58:51 +0000
Subject: [PATCH] WIPvariance

---
 tools/analysis/traceevent/src/buffer.rs | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/tools/analysis/traceevent/src/buffer.rs b/tools/analysis/traceevent/src/buffer.rs
index 147faad6ab..ef471ec48b 100644
--- a/tools/analysis/traceevent/src/buffer.rs
+++ b/tools/analysis/traceevent/src/buffer.rs
@@ -128,6 +128,8 @@ pub struct EventVisitor<'i, 'h, 'edm, InitDescF, T = ()> {
     // the only value we store back in the Cell is 'static (None) so that invariance is overkill.
     // In order to stay invariant in 'h, we use *mut insteaf of &'edm mut.
     desc_map: Cell<Option<*mut EventDescMap<T, InitDescF>>>,
+    _phantom_desc_map: PhantomData<&'edm mut ()>,
+
     scratch: &'i ScratchAlloc,
 
     // Unfortunately for now OnceCell<'h> makes EventVisitor invariant in 'h:
@@ -139,14 +141,6 @@ pub struct EventVisitor<'i, 'h, 'edm, InitDescF, T = ()> {
     // stored when the EventVisitor is created.
     event_desc: OnceCell<(*const EventDesc, *const T)>,
 
-    _phantom: PhantomData<(
-        &'h(),
-        // This is a lie. In reality, we have the equivalent of an &'edm mut EventDescMap, but we
-        // can't use &'edm mut (or *mut) because otherwise we conservatively become invariant in
-        // 'edm, whereas covariance is appropriate given how it is used (set once, with no risk of
-        // storing a value with lifetime that is too restricted).
-        &'edm ()
-    )>,
 }
 
 impl<'i, 'h, 'edm, InitDescF, T> EventVisitor<'i, 'h, 'edm, InitDescF, T> {
@@ -166,7 +160,7 @@ impl<'i, 'h, 'edm, InitDescF, T> EventVisitor<'i, 'h, 'edm, InitDescF, T> {
             scratch,
             desc_map: Cell::new(Some(desc_map)),
             event_desc: OnceCell::new(),
-            _phantom: PhantomData,
+            _phantom_desc_map: PhantomData,
         }
     }