#1147945 rust-tracing-core: Niche optimization assumption will fail for newer Rust

#1147945#5
Date:
2026-09-15 16:41:55 UTC
From:
To:
Dear rust-tracing-core maintainers,

Currently, rust-tracing-core assumes that Rust niche optimization[1]
remains the
same, even though Rust makes no such guarantee. As of Rust 1.97, this
hardcoded
assumption is no longer true, meaning that the
metadata::tests::level_filter_reprs
test will break[2]:

167s ---- metadata::tests::level_filter_reprs stdout ----
167s
167s thread 'metadata::tests::level_filter_reprs' (5315) panicked at
src/metadata.rs:1119:13:
167s assertion `left == right` failed: repr changed for LevelFilter::OFF
167s left: 5
167s right: 18446744073709551615
167s stack backtrace:
167s 0: __rustc::rust_begin_unwind
167s at /usr/src/rustc-1.97.1/library/std/src/panicking.rs:689:5
167s 1: core::panicking::panic_fmt
167s at /usr/src/rustc-1.97.1/library/core/src/panicking.rs:80:14
167s 2: core::panicking::assert_failed_inner
167s at /usr/src/rustc-1.97.1/library/core/src/panicking.rs:434:23
167s 3: core::panicking::assert_failed::<usize, usize>
167s at /usr/src/rustc-1.97.1/library/core/src/panicking.rs:394:5
167s 4: tracing_core::metadata::tests::level_filter_reprs
167s at ./src/metadata.rs:1119:13
167s 5: tracing_core::metadata::tests::level_filter_reprs::{closure#0}
167s at ./src/metadata.rs:1102:28
167s 6: <tracing_core::metadata::tests::level_filter_reprs::{closure#0} as
core::ops::function::FnOnce<()>>::call_once
167s at /usr/src/rustc-1.97.1/library/core/src/ops/function.rs:250:5
167s 7: <fn() -> core::result::Result<(), alloc::string::String> as
core::ops::function::FnOnce<()>>::call_once
167s at /usr/src/rustc-1.97.1/library/core/src/ops/function.rs:250:5
167s note: Some details are omitted, run with `RUST_BACKTRACE=full` for a
verbose backtrace.

Naturally, this bug will not impact Debian until Rust is updated to 1.97.
However, it is affecting Ubuntu and being tracked as LP: #2167368.

I have attached a patch which cherry-picks the upstream fix[3]. The fix
makes it so the crate works with all Rust versions past the MSRV -- I
successfully ran all tests with both 1.93.1 and 1.97.1, and I verified that
the package builds against Debian unstable.

Please let me know if you need anything else.

Best wishes,

Max

[1]: https://www.0xatticus.com/posts/understanding_rust_niche/
[2]:
https://autopkgtest.ubuntu.com/results/autopkgtest-stonking/stonking/amd64/r/rust-tracing-core/20260912_123714_a8bc3@/log.gz

[3]: https://github.com/tokio-rs/tracing/pull/3537