Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
Mar 25, 2022

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.

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 davidbarsky and a team 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