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

fix msrv (v0.1.x edition) #1581

Merged
merged 3 commits into from
Sep 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: check
args: --all --bins
args: --all

check:
# Run `cargo check` first to ensure that the pushed code at least compiles.
Expand All @@ -37,7 +37,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: check
args: --all --bins --tests --benches
args: --all --tests --benches

cargo-hack:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -279,4 +279,4 @@ jobs:
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all --bins --examples --tests --benches -- -D warnings
args: --all --examples --tests --benches -- -D warnings
23 changes: 14 additions & 9 deletions tracing-subscriber/src/filter/directive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,16 +312,21 @@ impl FromStr for StaticDirective {
));
}

if !maybe_fields.ends_with("}]") {
return Err(ParseError::msg("expected fields list to end with '}]'"));
}

let fields = maybe_fields
.strip_suffix("}]")
.ok_or_else(|| ParseError::msg("expected fields list to end with '}]'"))?;
field_names.extend(fields.split(',').filter_map(|s| {
if s.is_empty() {
None
} else {
Some(String::from(s))
}
}));
.trim_end_matches("}]")
.split(',')
.filter_map(|s| {
if s.is_empty() {
None
} else {
Some(String::from(s))
}
});
field_names.extend(fields);
};
let level = part1.parse()?;
return Ok(Self {
Expand Down
6 changes: 4 additions & 2 deletions tracing-subscriber/src/filter/env/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl fmt::Display for ValueMatch {
match self {
ValueMatch::Bool(ref inner) => fmt::Display::fmt(inner, f),
ValueMatch::F64(ref inner) => fmt::Display::fmt(inner, f),
ValueMatch::NaN => fmt::Display::fmt(&f64::NAN, f),
ValueMatch::NaN => fmt::Display::fmt(&std::f64::NAN, f),
ValueMatch::I64(ref inner) => fmt::Display::fmt(inner, f),
ValueMatch::U64(ref inner) => fmt::Display::fmt(inner, f),
ValueMatch::Pat(ref inner) => fmt::Display::fmt(inner, f),
Expand Down Expand Up @@ -355,7 +355,9 @@ impl<'a> Visit for MatchVisitor<'a> {
Some((ValueMatch::NaN, ref matched)) if value.is_nan() => {
matched.store(true, Release);
}
Some((ValueMatch::F64(ref e), ref matched)) if (value - *e).abs() < f64::EPSILON => {
Some((ValueMatch::F64(ref e), ref matched))
if (value - *e).abs() < std::f64::EPSILON =>
{
matched.store(true, Release);
}
_ => {}
Expand Down
12 changes: 7 additions & 5 deletions tracing-subscriber/src/filter/layer_filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ where

impl FilterId {
const fn disabled() -> Self {
Self(u64::MAX)
Self(std::u64::MAX)
}

/// Returns a `FilterId` that will consider _all_ spans enabled.
Expand Down Expand Up @@ -548,7 +548,7 @@ impl fmt::Binary for FilterId {

impl FilterMap {
pub(crate) fn set(self, FilterId(mask): FilterId, enabled: bool) -> Self {
if mask == u64::MAX {
if mask == std::u64::MAX {
return self;
}

Expand All @@ -570,7 +570,7 @@ impl FilterMap {

#[inline]
pub(crate) fn any_enabled(self) -> bool {
self.bits != u64::MAX
self.bits != std::u64::MAX
}
}

Expand Down Expand Up @@ -727,8 +727,10 @@ impl FilterState {
pub(crate) fn filter_map(&self) -> FilterMap {
let map = self.enabled.get();
#[cfg(debug_assertions)]
if self.counters.in_filter_pass.get() == 0 {
debug_assert_eq!(map, FilterMap::default());
{
if self.counters.in_filter_pass.get() == 0 {
debug_assert_eq!(map, FilterMap::default());
}
}

map
Expand Down
30 changes: 16 additions & 14 deletions tracing-subscriber/src/layer/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,20 +295,22 @@ where
// If we found a span, and our per-layer filter enables it, return that
// span!
#[cfg(feature = "registry")]
if let Some(span) = span?.try_with_filter(self.filter) {
Some(span)
} else {
// Otherwise, the span at the *top* of the stack is disabled by
// per-layer filtering, but there may be additional spans in the stack.
//
// Currently, `LookupSpan` doesn't have a nice way of exposing access to
// the whole span stack. However, if we can downcast the innermost
// subscriber to a a `Registry`, we can iterate over its current span
// stack.
//
// TODO(eliza): when https://github.com/tokio-rs/tracing/issues/1459 is
// implemented, change this to use that instead...
self.lookup_current_filtered(subscriber)
{
if let Some(span) = span?.try_with_filter(self.filter) {
Some(span)
} else {
// Otherwise, the span at the *top* of the stack is disabled by
// per-layer filtering, but there may be additional spans in the stack.
//
// Currently, `LookupSpan` doesn't have a nice way of exposing access to
// the whole span stack. However, if we can downcast the innermost
// subscriber to a a `Registry`, we can iterate over its current span
// stack.
//
// TODO(eliza): when https://github.com/tokio-rs/tracing/issues/1459 is
// implemented, change this to use that instead...
self.lookup_current_filtered(subscriber)
}
}

#[cfg(not(feature = "registry"))]
Expand Down
10 changes: 6 additions & 4 deletions tracing-subscriber/src/layer/layered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,12 @@ where
// for internal debugging purposes, so only print them if alternate mode
// is enabled.
#[cfg(feature = "registry")]
if alt {
s.field("inner_is_registry", &self.inner_is_registry)
.field("has_layer_filter", &self.has_layer_filter)
.field("inner_has_layer_filter", &self.inner_has_layer_filter);
{
if alt {
s.field("inner_is_registry", &self.inner_is_registry)
.field("has_layer_filter", &self.has_layer_filter)
.field("inner_has_layer_filter", &self.inner_has_layer_filter);
}
}

s.field("layer", &self.layer)
Expand Down
10 changes: 6 additions & 4 deletions tracing-subscriber/src/registry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,12 @@ where
// by the selected filter ID.

#[cfg(feature = "registry")]
if !curr.is_enabled_for(self.filter) {
// The current span in the chain is disabled for this
// filter. Try its parent.
continue;
{
if !curr.is_enabled_for(self.filter) {
// The current span in the chain is disabled for this
// filter. Try its parent.
continue;
}
}

return Some(curr);
Expand Down