diff --git a/tracing-core/src/field.rs b/tracing-core/src/field.rs index de564d8b3c..d7a01bb814 100644 --- a/tracing-core/src/field.rs +++ b/tracing-core/src/field.rs @@ -756,9 +756,6 @@ impl FieldSet { } /// Returns a new `ValueSet` with entries for this `FieldSet`'s values. - /// - /// Note that a `ValueSet` may not be constructed with arrays of over 32 - /// elements. #[doc(hidden)] pub fn value_set<'v, V>(&'v self, values: &'v V) -> ValueSet<'v> where @@ -957,28 +954,10 @@ impl<'a> fmt::Display for ValueSet<'a> { mod private { use super::*; - /// Marker trait implemented by arrays which are of valid length to - /// construct a `ValueSet`. - /// - /// `ValueSet`s may only be constructed from arrays containing 32 or fewer - /// elements, to ensure the array is small enough to always be allocated on the - /// stack. This trait is only implemented by arrays of an appropriate length, - /// ensuring that the correct size arrays are used at compile-time. + /// Restrictions on `ValueSet` lengths were removed in #2508 but this type remains for backwards compatibility. pub trait ValidLen<'a>: Borrow<[(&'a Field, Option<&'a (dyn Value + 'a)>)]> {} -} - -macro_rules! impl_valid_len { - ( $( $len:tt ),+ ) => { - $( - impl<'a> private::ValidLen<'a> for - [(&'a Field, ::core::option::Option<&'a (dyn Value + 'a)>); $len] {} - )+ - } -} -impl_valid_len! { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 + impl<'a, const N: usize> ValidLen<'a> for [(&'a Field, Option<&'a (dyn Value + 'a)>); N] {} } #[cfg(test)] diff --git a/tracing/src/lib.rs b/tracing/src/lib.rs index de54bffbd2..93cf6b2e37 100644 --- a/tracing/src/lib.rs +++ b/tracing/src/lib.rs @@ -386,22 +386,6 @@ //! span.record("parting", &"goodbye world!"); //! ``` //! -//! Note that a span may have up to 32 fields. The following will not compile: -//! -//! ```rust,compile_fail -//! # use tracing::Level; -//! # fn main() { -//! let bad_span = span!( -//! Level::TRACE, -//! "too many fields!", -//! a = 1, b = 2, c = 3, d = 4, e = 5, f = 6, g = 7, h = 8, i = 9, -//! j = 10, k = 11, l = 12, m = 13, n = 14, o = 15, p = 16, q = 17, -//! r = 18, s = 19, t = 20, u = 21, v = 22, w = 23, x = 24, y = 25, -//! z = 26, aa = 27, bb = 28, cc = 29, dd = 30, ee = 31, ff = 32, gg = 33 -//! ); -//! # } -//! ``` -//! //! Finally, events may also include human-readable messages, in the form of a //! [format string][fmt] and (optional) arguments, **after** the event's //! key-value fields. If a format string and arguments are provided, diff --git a/tracing/src/span.rs b/tracing/src/span.rs index 98d6ee12ef..ed58997b5a 100644 --- a/tracing/src/span.rs +++ b/tracing/src/span.rs @@ -22,7 +22,7 @@ //! override their default values. //! - The span's [verbosity level] //! - A string literal providing the span's name. -//! - Finally, between zero and 32 arbitrary key/value fields. +//! - Finally, zero or more arbitrary key/value fields. //! //! [`target`]: super::Metadata::target() //! diff --git a/tracing/tests/macros.rs b/tracing/tests/macros.rs index 6d9a333b68..6844315305 100644 --- a/tracing/tests/macros.rs +++ b/tracing/tests/macros.rs @@ -308,6 +308,48 @@ fn span_with_non_rust_symbol() { span!(Level::TRACE, "non-rust", "guid:x-request-id" = "abcdef"); } +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[test] +fn large_span() { + span!( + Level::TRACE, + "spans with more than 32 fields have been supported since #2508", + a = 1, + b = 2, + c = 3, + d = 4, + e = 5, + f = 6, + g = 7, + h = 8, + i = 9, + j = 10, + k = 11, + l = 12, + m = 13, + n = 14, + o = 15, + p = 16, + q = 17, + r = 18, + s = 19, + t = 20, + u = 21, + v = 22, + w = 23, + x = 24, + y = 25, + z = 26, + aa = 27, + bb = 28, + cc = 29, + dd = 30, + ee = 31, + ff = 32, + gg = 33 + ); +} + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[test] fn event() {