Skip to content

subscriber: make FmtSubscriber's auto traits not depend on C#2024

Merged
hawkw merged 6 commits intomasterfrom
eliza/fix-subscriber-phantom
Mar 25, 2022
Merged

subscriber: make FmtSubscriber's auto traits not depend on C#2024
hawkw merged 6 commits intomasterfrom
eliza/fix-subscriber-phantom

Conversation

@hawkw
Copy link
Member

@hawkw hawkw commented Mar 25, 2022

Depends on #2023

Motivation

Currently, FmtSubscriber holds a PhantomData<C> with the Collect
type it wraps. This is unfortunate because it means that the
subscriber's auto traits such as Send, Sync, and 'static (as well
as UnwindSafe, Unpin, etc) depend on the collector type's auto
traits...but the subscriber will never actually store a value of type
C. While all collectors will be Send + Sync + 'static in practice,
the PhantomData means that functions returning a boxed FmtSubscriber
must unnecessarily bound the collector type parameter.

Solution

This commit changes the PhantomData to PhantomData<fn(C)>, solving
the problem.

hawkw added 5 commits March 25, 2022 10:50
this moves the "runtime configuration with subscribers" section into a
subsection of "composing subscribers".

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
## Motivation

Currently, `FmtSubscriber` holds a `PhantomData<C>` with the `Collect`
type it wraps. This is unfortunate because it means that the
subscriber's auto traits such as `Send`, `Sync`, and `'static` (as well
as `UnwindSafe`, `Unpin`, etc) depend on the collector type's auto
traits...but the subscriber will never actually _store_ a value of type
`C`. While all collectors will be `Send + Sync + 'static` in practice,
the `PhantomData` means that functions returning a boxed `FmtSubscriber`
must unnecessarily bound the collector type parameter.

## Solution

This commit changes the `PhantomData` to `PhantomData<fn(C)>`, solving
the problem.
@hawkw hawkw requested review from a team and davidbarsky as code owners March 25, 2022 18:19
Base automatically changed from eliza/fix-box to master March 25, 2022 18:38
@hawkw hawkw enabled auto-merge (squash) March 25, 2022 19:02
@hawkw hawkw merged commit c1de498 into master Mar 25, 2022
@hawkw hawkw deleted the eliza/fix-subscriber-phantom branch March 25, 2022 19:21
hawkw added a commit that referenced this pull request Mar 29, 2022
Depends on #2023

## Motivation

Currently, `FmtLayer` holds a `PhantomData<S>` with the `Subscriber`
type it wraps. This is unfortunate because it means that the
layer's auto traits such as `Send`, `Sync`, and `'static` (as well
as `UnwindSafe`, `Unpin`, etc) depend on the `Subscriber` type's auto
traits...but the layer will never actually _store_ a value of type
`S`. While all `Subscriber` will be `Send + Sync + 'static` in practice,
the `PhantomData` means that functions returning a boxed `FmtLayer`
must unnecessarily bound the subscriber type parameter.

## Solution

This commit changes the `PhantomData` to `PhantomData<fn(S)>`, solving
the problem.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
hawkw added a commit that referenced this pull request Mar 29, 2022
Depends on #2023

## Motivation

Currently, `FmtLayer` holds a `PhantomData<S>` with the `Subscriber`
type it wraps. This is unfortunate because it means that the
layer's auto traits such as `Send`, `Sync`, and `'static` (as well
as `UnwindSafe`, `Unpin`, etc) depend on the `Subscriber` type's auto
traits...but the layer will never actually _store_ a value of type
`S`. While all `Subscriber` will be `Send + Sync + 'static` in practice,
the `PhantomData` means that functions returning a boxed `FmtLayer`
must unnecessarily bound the subscriber type parameter.

## Solution

This commit changes the `PhantomData` to `PhantomData<fn(S)>`, solving
the problem.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
kaffarell pushed a commit to kaffarell/tracing that referenced this pull request May 22, 2024
)

Depends on tokio-rs#2023

## Motivation

Currently, `FmtLayer` holds a `PhantomData<S>` with the `Subscriber`
type it wraps. This is unfortunate because it means that the
layer's auto traits such as `Send`, `Sync`, and `'static` (as well
as `UnwindSafe`, `Unpin`, etc) depend on the `Subscriber` type's auto
traits...but the layer will never actually _store_ a value of type
`S`. While all `Subscriber` will be `Send + Sync + 'static` in practice,
the `PhantomData` means that functions returning a boxed `FmtLayer`
must unnecessarily bound the subscriber type parameter.

## Solution

This commit changes the `PhantomData` to `PhantomData<fn(S)>`, solving
the problem.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants