1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
use core::any::TypeId;
use rootcause_internals::{
RawAttachment,
handlers::{AttachmentFormattingStyle, FormattingFunction},
};
use crate::{
handlers::{self, AttachmentHandler},
markers::{self, Dynamic, Local, SendSync},
preformatted::PreformattedAttachment,
report_attachment::{ReportAttachmentMut, ReportAttachmentRef},
};
/// FIXME: Once rust-lang/rust#132922 gets resolved, we can make the `raw` field
/// an unsafe field and remove this module.
mod limit_field_access {
use core::marker::PhantomData;
use rootcause_internals::{RawAttachment, RawAttachmentMut, RawAttachmentRef};
use crate::markers::{Dynamic, SendSync};
/// An attachment to be attached to a [`Report`](crate::Report).
///
/// Attachments can hold any type of data, and can be formatted using custom
/// handlers. The attachment can be marked as either [`SendSync`] or
/// [`Local`], indicating whether it is safe to send the attachment
/// across threads or not.
///
/// # Type Parameters
/// - `Attachment`: The type of the attachment. This can either be a
/// concrete type, or [`Dynamic`].
/// - `ThreadSafety`: The thread safety marker for the attachment. This can
/// either be [`SendSync`] or [`Local`].
///
/// [`SendSync`]: crate::markers::SendSync
/// [`Local`]: crate::markers::Local
#[repr(transparent)]
pub struct ReportAttachment<
Attachment: ?Sized + 'static = Dynamic,
ThreadSafety: 'static = SendSync,
> {
/// # Safety
///
/// The following safety invariants are guaranteed to be upheld as long
/// as this struct exists:
///
/// 1. `A` must either be a type bounded by `Sized`, or `Dynamic`.
/// 2. `T` must either be `SendSync` or `Local`.
/// 3. If `A` is a `Sized` type: The attachment embedded in the
/// [`RawAttachment`] must be of type `A`.
/// 4. If `T = SendSync`: The attachment embedded in the
/// [`RawAttachment`] must be `Send + Sync`.
raw: RawAttachment,
_attachment: PhantomData<Attachment>,
_thread_safety: PhantomData<ThreadSafety>,
}
impl<A: ?Sized, T> ReportAttachment<A, T> {
/// Creates a new Attachment from a raw attachment
///
/// # Safety
///
/// The caller must ensure:
///
/// 1. `A` must either be a type bounded by `Sized`, or `Dynamic`.
/// 2. `T` must either be `SendSync` or `Local`.
/// 3. If `A` is a `Sized` type: The attachment embedded in the
/// [`RawAttachment`] must be of type `A`.
/// 4. If `T = SendSync`: The attachment embedded in the
/// [`RawAttachment`] must be `Send + Sync`.
#[must_use]
pub(crate) unsafe fn from_raw(raw: RawAttachment) -> Self {
// SAFETY: We must uphold the safety invariants of the raw field:
// 1. Guaranteed by caller
// 2. Guaranteed by caller
// 3. Guaranteed by caller
// 4. Guaranteed by caller
ReportAttachment {
raw,
_attachment: PhantomData,
_thread_safety: PhantomData,
}
}
/// Consumes the [`ReportAttachment`] and returns the inner
/// [`RawAttachment`].
#[must_use]
pub(crate) fn into_raw(self) -> RawAttachment {
// SAFETY: We are destroying `self`, so we no longer
// need to uphold any safety invariants.
self.raw
}
/// Creates a lifetime-bound [`RawAttachmentRef`] from the inner
/// [`RawAttachment`].
///
/// This returns a raw, read-only reference to the same attachment, but with a
/// lifetime tied to the lifetime of `self`.
///
/// # Guarantees
///
/// The returned `RawAttachmentRef` refers to the same attachment data as
/// this `ReportAttachment`, preserving the attachment's type.
#[must_use]
pub(crate) fn as_raw_ref(&self) -> RawAttachmentRef<'_> {
// SAFETY: We must uphold the safety invariants of the raw field:
// 1. Upheld as the type parameters do not change.
// 2. Upheld as the type parameters do not change.
// 3. No mutation is possible through the `RawAttachmentRef`
// 4. No mutation is possible through the `RawAttachmentRef`
let raw = &self.raw;
raw.as_ref()
}
/// Creates a lifetime-bound [`RawAttachmentMut`] from the inner
/// [`RawAttachment`]
///
/// This returns a raw, mutable reference to the same attachment, but with a
/// lifetime tied to the lifetime of `self`.
///
/// # Guarantees
///
/// The returned `RawAttachmentMut` refers to the same attachment data as
/// this `ReportAttachment`, preserving the attachment's type.
#[must_use]
pub(crate) fn as_raw_mut(&mut self) -> RawAttachmentMut<'_> {
// SAFETY: We must uphold the safety invariants of the raw field:
// 1. Upheld as the type parameters do not change.
// 2. Upheld as the type parameters do not change.
// 3. While mutation is possible through the `RawAttachmentMut`, it's
// not possible to change the type of the attachment.
// 4. While mutation is possible through the `RawAttachmentMut`, it's
// not possible to change the type of the attachment.
let raw = &mut self.raw;
raw.as_mut()
}
}
}
pub use limit_field_access::ReportAttachment;
impl<A: Sized, T> ReportAttachment<A, T> {
/// Allocates a new [`ReportAttachment`] with the given attachment as the
/// data.
///
/// The new attachment will use the [`handlers::Display`] handler to format
/// the attachment. See [`ReportAttachment::new_custom`] if you want to
/// control the handler used.
///
/// # Examples
/// ```
/// use rootcause::{prelude::*, report_attachment::ReportAttachment};
///
/// let attachment = ReportAttachment::new("This is an attachment");
/// let mut report = report!("An error occurred");
/// report.attachments_mut().push(attachment.into_dynamic());
/// ```
#[must_use]
pub fn new(attachment: A) -> Self
where
A: markers::ObjectMarkerFor<T> + core::fmt::Display + core::fmt::Debug,
{
Self::new_custom::<handlers::Display>(attachment)
}
/// Allocates a new [`ReportAttachment`] with the given attachment as the
/// data and the given handler to format it.
///
/// # Examples
/// ```
/// use rootcause::{prelude::*, report_attachment::ReportAttachment};
///
/// #[derive(Debug)]
/// struct MyAttachmentType {
/// data: String,
/// }
/// let attachment = ReportAttachment::new_custom::<handlers::Debug>(MyAttachmentType {
/// data: "Important data".to_string(),
/// });
/// let mut report = report!("An error occurred");
/// report.attachments_mut().push(attachment.into_dynamic());
/// ```
#[must_use]
pub fn new_custom<H>(attachment: A) -> Self
where
A: markers::ObjectMarkerFor<T>,
H: AttachmentHandler<A>,
{
let raw = RawAttachment::new::<A, H>(attachment);
// SAFETY:
// 1. `A` is bounded by `Sized` in this impl, so this is trivially true.
// 2. `A` is bounded by `markers::ObjectMarkerFor<T>` and this can only be
// implemented for `T=Local` and `T=SendSync`, so this is
// upheld.
// 3. We just created the `RawAttachment` and it does indeed have an attachment
// of type `A`.
// 4. If `T=Local`, then this is trivially true. If `T=SendSync`, then the bound
// `A: ObjectMarkerFor<SendSync>` guarantees that the attachment is
// `Send+Sync`.
unsafe {
// @add-unsafe-context: markers::ObjectMarkerFor
ReportAttachment::from_raw(raw)
}
}
/// Returns a reference to the inner attachment.
///
/// This method is only available when the attachment type is a specific
/// type, and not [`Dynamic`].
#[must_use]
pub fn inner(&self) -> &A {
self.as_ref().inner()
}
/// Returns a mutable reference to the inner attachment.
///
/// This method is only available when the attachment type is a specific
/// type, and not [`Dynamic`].
#[must_use]
pub fn inner_mut(&mut self) -> &mut A {
self.as_mut().into_inner_mut()
}
}
impl<A: ?Sized, T> ReportAttachment<A, T> {
/// Changes the inner attachment type of the [`ReportAttachment`] to
/// [`Dynamic`]
///
/// Calling this method is equivalent to calling `attachment.into()`,
/// however this method has been restricted to only change the
/// attachment type to [`Dynamic`].
///
/// This method can be useful to help with type inference or to improve code
/// readability, as it more clearly communicates intent.
///
/// This method does not actually modify the attachment in any way. It only
/// has the effect of "forgetting" that the inner attachment actually has
/// the type `A`.
///
/// To get back the attachment with a concrete `A` you can use the method
/// [`ReportAttachment::downcast_attachment`].
#[must_use]
pub fn into_dynamic(self) -> ReportAttachment<Dynamic, T> {
let raw = self.into_raw();
// SAFETY:
// 1. `A=Dynamic`, so this is trivially true.
// 2. Guaranteed by the invariants of this type.
// 3. `A=Dynamic`, so this is trivially true.
// 4. Guaranteed by the invariants of this type.
unsafe {
// @add-unsafe-context: Dynamic
ReportAttachment::<Dynamic, T>::from_raw(raw)
}
}
/// Changes the thread safety mode of the [`ReportAttachment`] to [`Local`].
///
/// Calling this method is equivalent to calling `attachment.into()`,
/// however this method has been restricted to only change the thread
/// safety mode to [`Local`].
///
/// This method can be useful to help with type inference or to improve code
/// readability, as it more clearly communicates intent.
///
/// This method does not actually modify the attachment in any way. It only
/// has the effect of "forgetting" that the object in the
/// [`ReportAttachment`] might actually be [`Send`] and [`Sync`].
#[must_use]
pub fn into_local(self) -> ReportAttachment<A, Local> {
let raw = self.into_raw();
// SAFETY:
// 1. Guaranteed by the invariants of this type.
// 2. `T=Local`, so this is trivially true.
// 3. Guaranteed by the invariants of this type.
// 4. `T=Local`, so this is trivially true.
unsafe { ReportAttachment::from_raw(raw) }
}
/// Returns the [`TypeId`] of the inner attachment.
#[must_use]
pub fn inner_type_id(&self) -> TypeId {
self.as_raw_ref().attachment_type_id()
}
/// Returns the [`core::any::type_name`] of the inner attachment.
#[must_use]
pub fn inner_type_name(&self) -> &'static str {
self.as_raw_ref().attachment_type_name()
}
/// Returns the [`TypeId`] of the handler used when creating this
/// attachment.
#[must_use]
pub fn inner_handler_type_id(&self) -> TypeId {
self.as_raw_ref().attachment_handler_type_id()
}
/// Formats the attachment with hook processing.
#[must_use]
pub fn format_inner(&self) -> impl core::fmt::Display + core::fmt::Debug {
self.as_ref().format_inner()
}
/// Formats the attachment without hook processing.
#[must_use]
pub fn format_inner_unhooked(&self) -> impl core::fmt::Display + core::fmt::Debug {
self.as_ref().format_inner_unhooked()
}
/// Gets the preferred formatting style for the attachment with hook
/// processing.
///
/// # Arguments
///
/// - `report_formatting_function`: Whether the report in which this
/// attachment will be embedded is being formatted using [`Display`]
/// formatting or [`Debug`]
///
/// [`Display`]: core::fmt::Display
/// [`Debug`]: core::fmt::Debug
#[must_use]
pub fn preferred_formatting_style(
&self,
report_formatting_function: FormattingFunction,
) -> AttachmentFormattingStyle {
self.as_ref()
.preferred_formatting_style(report_formatting_function)
}
/// Gets the preferred formatting style for the attachment without hook
/// processing.
///
/// # Arguments
///
/// - `report_formatting_function`: Whether the report in which this
/// attachment will be embedded is being formatted using [`Display`]
/// formatting or [`Debug`]
///
/// [`Display`]: core::fmt::Display
/// [`Debug`]: core::fmt::Debug
#[must_use]
pub fn preferred_formatting_style_unhooked(
&self,
report_formatting_function: FormattingFunction,
) -> AttachmentFormattingStyle {
self.as_raw_ref()
.preferred_formatting_style(report_formatting_function)
}
/// Returns a reference to the attachment.
#[must_use]
pub fn as_ref(&self) -> ReportAttachmentRef<'_, A> {
let raw = self.as_raw_ref();
// SAFETY: The safety requirements for `ReportAttachmentRef::from_raw` are upheld:
// 1. The type parameter `A` is either `Sized` or `Dynamic` (enforced by this type's
// documented invariants)
// 2. If `A` is `Sized`, the attachment in `raw` is of type `A` because `as_raw_ref()`
// returns a reference to the same underlying attachment data that this
// `ReportAttachment<A>` wraps, which satisfies this type's invariant
unsafe { ReportAttachmentRef::from_raw(raw) }
}
/// Returns a mutable reference to the attachment.
#[must_use]
pub fn as_mut(&mut self) -> ReportAttachmentMut<'_, A> {
let raw = self.as_raw_mut();
// SAFETY: The safety requirements for `ReportAttachmentMut::from_raw` are upheld:
// 1. The type parameter `A` is either `Sized` or `Dynamic` (enforced by this type's
// documented invariants)
// 2. If `A` is `Sized`, the attachment in `raw` is of type `A` because `as_raw_mut()`
// returns a mutable reference to the same underlying attachment data that this
// `ReportAttachment<A>` wraps, which satisfies this type's invariant
unsafe { ReportAttachmentMut::from_raw(raw) }
}
/// Creates a new attachment, with the inner attachment data preformatted.
///
/// This can be useful, as the preformatted attachment is a newly allocated
/// object and additionally is [`Send`]+[`Sync`].
///
/// See [`PreformattedAttachment`] for more information.
///
/// [`PreformattedAttachment`](crate::preformatted::PreformattedAttachment)
#[must_use]
#[track_caller]
pub fn preformat(&self) -> ReportAttachment<PreformattedAttachment, SendSync> {
// For implementation reasons, the actual formatting works on
// ReportAttachmentRef
self.as_ref().preformat()
}
}
impl<A: Sized + Send + Sync> ReportAttachment<A, SendSync> {
/// Creates a new [`ReportAttachment`] with [`SendSync`] thread safety.
///
/// This is a convenience method that calls [`ReportAttachment::new`] with
/// explicit [`SendSync`] thread safety. Use this method when you're
/// having trouble with type inference for the thread safety parameter.
///
/// The attachment will use the [`handlers::Display`] handler to format the
/// attachment.
#[must_use]
pub fn new_sendsync(attachment: A) -> Self
where
A: core::fmt::Display + core::fmt::Debug,
{
Self::new(attachment)
}
/// Creates a new [`ReportAttachment`] with [`SendSync`] thread safety and
/// the given handler.
///
/// This is a convenience method that calls [`ReportAttachment::new_custom`]
/// with explicit [`SendSync`] thread safety. Use this method when
/// you're having trouble with type inference for the thread safety
/// parameter.
#[must_use]
pub fn new_sendsync_custom<H>(attachment: A) -> Self
where
H: AttachmentHandler<A>,
{
Self::new_custom::<H>(attachment)
}
}
impl<A: Sized> ReportAttachment<A, Local> {
/// Creates a new [`ReportAttachment`] with [`Local`] thread safety.
///
/// This is a convenience method that calls [`ReportAttachment::new`] with
/// explicit [`Local`] thread safety. Use this method when you're having
/// trouble with type inference for the thread safety parameter.
///
/// The attachment will use the [`handlers::Display`] handler to format the
/// attachment.
#[must_use]
pub fn new_local(attachment: A) -> Self
where
A: core::fmt::Display + core::fmt::Debug,
{
Self::new_custom::<handlers::Display>(attachment)
}
/// Creates a new [`ReportAttachment`] with [`Local`] thread safety and the
/// given handler.
///
/// This is a convenience method that calls [`ReportAttachment::new_custom`]
/// with explicit [`Local`] thread safety. Use this method when you're
/// having trouble with type inference for the thread safety parameter.
#[must_use]
pub fn new_local_custom<H>(attachment: A) -> Self
where
H: AttachmentHandler<A>,
{
Self::new_custom::<H>(attachment)
}
}
impl<T> ReportAttachment<Dynamic, T> {
/// Attempts to downcast the inner attachment to a specific type.
///
/// Returns `Some(&A)` if the inner attachment is of type `A`, otherwise
/// returns `None`.
#[must_use]
pub fn downcast_inner<A>(&self) -> Option<&A>
where
A: Sized + 'static,
{
self.as_ref().downcast_inner()
}
/// Downcasts the inner attachment to a specific type without checking.
///
/// # Safety
///
/// The caller must ensure:
///
/// 1. The inner attachment is actually of type `A` (can be verified by
/// calling [`inner_type_id()`] first)
///
/// [`inner_type_id()`]: ReportAttachment::inner_type_id
#[must_use]
pub unsafe fn downcast_inner_unchecked<A>(&self) -> &A
where
A: Sized + 'static,
{
let raw = self.as_raw_ref();
// SAFETY:
// 1. Guaranteed by the caller
unsafe { raw.attachment_downcast_unchecked() }
}
/// Attempts to downcast the inner attachment to a specific type.
///
/// Returns `Some(&mut A)` if the inner attachment is of type `A`, otherwise
/// returns `None`.
#[must_use]
pub fn downcast_inner_mut<A>(&mut self) -> Option<&mut A>
where
A: Sized + 'static,
{
let mut_ = self.as_mut().downcast_attachment().ok()?;
Some(mut_.into_inner_mut())
}
/// Downcasts the inner attachment to a specific type without checking.
///
/// # Safety
///
/// The caller must ensure:
///
/// 1. The inner attachment is actually of type `A` (can be verified by
/// calling [`inner_type_id()`] first)
///
/// [`inner_type_id()`]: ReportAttachment::inner_type_id
#[must_use]
pub unsafe fn downcast_inner_mut_unchecked<A>(&mut self) -> &mut A
where
A: Sized + 'static,
{
let raw = self.as_raw_mut();
// SAFETY:
// 1. Guaranteed by the caller
unsafe { raw.into_attachment_downcast_unchecked() }
}
/// Attempts to downcast the [`ReportAttachment`] to a specific attachment
/// type.
///
/// Returns `Ok(attachment)` if the inner attachment is of type `A`,
/// otherwise returns `Err(self)` with the original [`ReportAttachment`].
pub fn downcast_attachment<A>(self) -> Result<ReportAttachment<A, T>, Self>
where
A: Sized + 'static,
{
if TypeId::of::<A>() == self.inner_type_id() {
// SAFETY:
// 1. We just checked that the type IDs match
let attachment = unsafe { self.downcast_unchecked() };
Ok(attachment)
} else {
Err(self)
}
}
/// Downcasts the [`ReportAttachment`] to a specific attachment type without
/// checking.
///
/// # Safety
///
/// The caller must ensure:
///
/// 1. The inner attachment is actually of type `A` (can be verified by
/// calling [`inner_type_id()`] first)
///
/// [`inner_type_id()`]: ReportAttachment::inner_type_id
#[must_use]
pub unsafe fn downcast_unchecked<A>(self) -> ReportAttachment<A, T>
where
A: Sized + 'static,
{
let raw = self.into_raw();
// SAFETY:
// 1. `A` is bounded by `Sized`, so this is trivially true.
// 2. Guaranteed by the invariants of this type.
// 3. Guaranteed by the caller
// 4. Guaranteed by the invariants of this type.
unsafe { ReportAttachment::<A, T>::from_raw(raw) }
}
}
impl<A: Sized, T> From<A> for ReportAttachment<A, T>
where
A: markers::ObjectMarkerFor<T> + core::fmt::Display + core::fmt::Debug,
{
fn from(attachment: A) -> Self {
ReportAttachment::new_custom::<handlers::Display>(attachment)
}
}
impl<A: Sized, T> From<A> for ReportAttachment<Dynamic, T>
where
A: markers::ObjectMarkerFor<T> + core::fmt::Display + core::fmt::Debug,
{
fn from(attachment: A) -> Self {
ReportAttachment::new_custom::<handlers::Display>(attachment).into_dynamic()
}
}
// SAFETY: The `SendSync` marker indicates that the inner attachment
// is `Send`+`Sync`. Therefore it is safe to implement `Send`+`Sync` for the
// attachment itself.
unsafe impl<A: ?Sized> Send for ReportAttachment<A, SendSync> {}
// SAFETY: The `SendSync` marker indicates that the inner attachment
// is `Send`+`Sync`. Therefore it is safe to implement `Send`+`Sync` for the
// attachment itself.
unsafe impl<A: ?Sized> Sync for ReportAttachment<A, SendSync> {}
impl<A: ?Sized, T> Unpin for ReportAttachment<A, T> {}
macro_rules! from_impls {
($(
<
$($param:ident),*
>:
$attachment1:ty => $attachment2:ty,
$thread_safety1:ty => $thread_safety2:ty,
[$($op:ident),*]
),* $(,)?) => {
$(
impl<$($param),*> From<ReportAttachment<$attachment1, $thread_safety1>> for ReportAttachment<$attachment2, $thread_safety2>
{
fn from(attachment: ReportAttachment<$attachment1, $thread_safety1>) -> Self {
attachment
$(
.$op()
)*
}
}
)*
};
}
from_impls!(
<A>: A => A, SendSync => Local, [into_local],
<A>: A => Dynamic, SendSync => SendSync, [into_dynamic],
<A>: A => Dynamic, SendSync => Local, [into_dynamic, into_local],
<A>: A => Dynamic, Local => Local, [into_dynamic],
<>: Dynamic => Dynamic, SendSync => Local, [into_local],
);
#[cfg(test)]
mod tests {
use alloc::string::String;
use super::*;
#[allow(dead_code)]
struct NonSend(*const ());
static_assertions::assert_not_impl_any!(NonSend: Send, Sync);
#[test]
fn test_attachment_send_sync() {
static_assertions::assert_impl_all!(ReportAttachment<(), SendSync>: Send, Sync);
static_assertions::assert_impl_all!(ReportAttachment<String, SendSync>: Send, Sync);
static_assertions::assert_impl_all!(ReportAttachment<NonSend, SendSync>: Send, Sync);
static_assertions::assert_impl_all!(ReportAttachment<Dynamic, SendSync>: Send, Sync);
static_assertions::assert_not_impl_any!(ReportAttachment<(), Local>: Send, Sync);
static_assertions::assert_not_impl_any!(ReportAttachment<String, Local>: Send, Sync);
static_assertions::assert_not_impl_any!(ReportAttachment<NonSend, Local>: Send, Sync);
static_assertions::assert_not_impl_any!(ReportAttachment<Dynamic, Local>: Send, Sync);
}
#[test]
fn test_attachment_unpin() {
static_assertions::assert_impl_all!(ReportAttachment<(), SendSync>: Unpin);
static_assertions::assert_impl_all!(ReportAttachment<String, SendSync>: Unpin);
static_assertions::assert_impl_all!(ReportAttachment<NonSend, SendSync>: Unpin);
static_assertions::assert_impl_all!(ReportAttachment<Dynamic, SendSync>: Unpin);
static_assertions::assert_impl_all!(ReportAttachment<(), Local>: Unpin);
static_assertions::assert_impl_all!(ReportAttachment<String, Local>: Unpin);
static_assertions::assert_impl_all!(ReportAttachment<NonSend, Local>: Unpin);
static_assertions::assert_impl_all!(ReportAttachment<Dynamic, Local>: Unpin);
}
#[test]
fn test_attachment_copy_clone() {
static_assertions::assert_not_impl_any!(ReportAttachment<(), SendSync>: Copy, Clone);
static_assertions::assert_not_impl_any!(ReportAttachment<String, SendSync>: Copy, Clone);
static_assertions::assert_not_impl_any!(ReportAttachment<NonSend, SendSync>: Copy, Clone);
static_assertions::assert_not_impl_any!(ReportAttachment<Dynamic, SendSync>: Copy, Clone);
static_assertions::assert_not_impl_any!(ReportAttachment<(), Local>: Copy, Clone);
static_assertions::assert_not_impl_any!(ReportAttachment<String, Local>: Copy, Clone);
static_assertions::assert_not_impl_any!(ReportAttachment<NonSend, Local>: Copy, Clone);
static_assertions::assert_not_impl_any!(ReportAttachment<Dynamic, Local>: Copy, Clone);
}
}