From 1a9ee003ce22f481187db037507b4d106d090041 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Thu, 3 Feb 2022 13:50:58 -0800 Subject: [PATCH] ci: add `tracing_unstable` to CI (#1894) * ci: add `tracing_unstable` to CI Currently, the `valuable` support requires the `tracing_unstable` cfg to be set. Because none of our current CI jobs set this, we aren't currently testing that code, and have no way of even ensuring that it compiles. This is Bad. This PR adds a CI job to run tests with the unstable cfg enabled. * core: fix wrong `self` types with `valuable` This should fix the build. Signed-off-by: Eliza Weisman --- .github/workflows/CI.yml | 20 ++++++++++++++++++++ examples/examples/valuable_instrument.rs | 2 +- tracing-core/src/field.rs | 4 ++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d41b47c9..1ca6969d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -270,6 +270,26 @@ jobs: command: test args: --all + test-unstable: + # Test the `tracing-unstable` cfg flags + env: + RUSTFLAGS: "--cfg tracing_unstable" + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + - name: Run tests + uses: actions-rs/cargo@v1 + with: + command: test + args: --all --features "valuable" + + features-stable: # Feature flag tests that run on stable Rust. # TODO(david): once tracing's MSRV goes up to Rust 1.51, we should be able to switch to diff --git a/examples/examples/valuable_instrument.rs b/examples/examples/valuable_instrument.rs index a8f93b5a..729ebc67 100644 --- a/examples/examples/valuable_instrument.rs +++ b/examples/examples/valuable_instrument.rs @@ -2,7 +2,7 @@ mod app { use std::collections::HashMap; use tracing::field::valuable; - use tracing::{info, info_span, instrument}; + use tracing::{info, instrument}; use valuable::Valuable; #[derive(Valuable)] diff --git a/tracing-core/src/field.rs b/tracing-core/src/field.rs index 1a11f6bc..e5c4cc75 100644 --- a/tracing-core/src/field.rs +++ b/tracing-core/src/field.rs @@ -643,7 +643,7 @@ impl crate::sealed::Sealed for valuable::Value<'_> {} #[cfg_attr(docsrs, doc(cfg(all(tracing_unstable, feature = "valuable"))))] impl Value for valuable::Value<'_> { fn record(&self, key: &Field, visitor: &mut dyn Visit) { - visitor.record_value(key, self) + visitor.record_value(key, *self) } } @@ -654,7 +654,7 @@ impl crate::sealed::Sealed for &'_ dyn valuable::Valuable {} #[cfg_attr(docsrs, doc(cfg(all(tracing_unstable, feature = "valuable"))))] impl Value for &'_ dyn valuable::Valuable { fn record(&self, key: &Field, visitor: &mut dyn Visit) { - visitor.record_value(key, &self.as_value()) + visitor.record_value(key, self.as_value()) } }