Skip to content

Commit

Permalink
subscriber: fix unused method warnings for Extensions (#1686)
Browse files Browse the repository at this point in the history
## Motivation

Currently, there are some `pub(crate)` methods on the `Extensions`,
`ExtensionsMut`, and `ExtensionsInner` types that are only used when the
"registry" feature is enabled. However, the _types_ exist when the "std"
feature flag is enabled, so those methods produce unused method
warnings.

## Solution

This commit adds `#[cfg(feature = "registry")]` to those methods, fixing
the warning.
  • Loading branch information
hawkw authored Oct 25, 2021
1 parent a5aab95 commit 3392be9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tracing-subscriber/src/registry/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub struct Extensions<'a> {
}

impl<'a> Extensions<'a> {
#[cfg(feature = "registry")]
pub(crate) fn new(inner: RwLockReadGuard<'a, ExtensionsInner>) -> Self {
Self { inner }
}
Expand All @@ -59,6 +60,7 @@ pub struct ExtensionsMut<'a> {
}

impl<'a> ExtensionsMut<'a> {
#[cfg(feature = "registry")]
pub(crate) fn new(inner: RwLockWriteGuard<'a, ExtensionsInner>) -> Self {
Self { inner }
}
Expand Down Expand Up @@ -120,6 +122,7 @@ pub(crate) struct ExtensionsInner {

impl ExtensionsInner {
/// Create an empty `Extensions`.
#[cfg(any(test, feature = "registry"))]
#[inline]
pub(crate) fn new() -> ExtensionsInner {
ExtensionsInner {
Expand Down Expand Up @@ -179,6 +182,7 @@ impl ExtensionsInner {
///
/// This permits the hash map allocation to be pooled by the registry so
/// that future spans will not need to allocate new hashmaps.
#[cfg(any(test, feature = "registry"))]
pub(crate) fn clear(&mut self) {
self.map.clear();
}
Expand Down

0 comments on commit 3392be9

Please sign in to comment.