Skip to content

Commit

Permalink
WIPvariance
Browse files Browse the repository at this point in the history
  • Loading branch information
douglas-raillard-arm committed Nov 14, 2023
1 parent f110469 commit 07f102c
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions tools/analysis/traceevent/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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> {
Expand All @@ -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,
}
}

Expand Down

0 comments on commit 07f102c

Please sign in to comment.