Bound attribute value types Send and Sync

This commit is contained in:
Dennis Kobert
2026-09-08 13:14:59 +00:00
parent ad03b5b0bf
commit 682d3dafbd
2 changed files with 9 additions and 4 deletions

View File

@@ -28,7 +28,11 @@ pub trait Attribute: 'static {
/// is the evaluation the value flows in; non-reference values ignore it.
/// The value outlives that evaluation, so its `'static` instantiation is
/// the one the census registers and layouts stamp their type id from.
type Value<'e>: Copy + Default + std::fmt::Debug + 'e;
///
/// `Send + Sync` because a record's bytes are these values: `RecordValue`
/// is `Send + Sync` over whatever the field writes put there, and the write
/// path never consults the census, so the bound has to sit here.
type Value<'e>: Copy + Default + std::fmt::Debug + Send + Sync + 'e;
/// The name-specific default, filled where an item lacks the attribute.
/// Producing a value for any `'e` from no inputs, reference defaults can
/// only point at `'static` data, which is what lets the census fill them

View File

@@ -50,9 +50,10 @@ impl std::fmt::Debug for RecordValue<'_> {
}
}
// SAFETY: `element_write` requires the element `Send + Sync` and attribute payloads
// are `Copy` or arena-backed, so the record bytes behind the pointer are thread-safe;
// `'e` ties the pointer's validity to the shared arena and record-stack discipline.
// SAFETY: `element_write` requires the element `Send + Sync` and every field holds an
// `Attribute::Value`, which the trait bounds `Send + Sync`, so the record bytes behind
// the pointer are thread-safe; `'e` ties the pointer's validity to the shared arena and
// record-stack discipline.
unsafe impl Send for RecordValue<'_> {}
// SAFETY: as `Send`.
unsafe impl Sync for RecordValue<'_> {}