ITADN

Fix inconsistent traces/tracing feature gating (#154)

#194Pull Requestgftea 创建于 2026-05-24
G
gfteacommented
## Summary Fixes #154. The `traces` cargo feature was inconsistently gated in the codebase: - The Cargo.toml defined `traces = ["tracing"]`, which Cargo turned into an *implicit* `tracing` feature (because `tracing` is also an optional dependency). - A handful of `#[cfg(...)]` checks referenced `feature = "tracing"` instead of `feature = "traces"`. Enabling `traces` happened to work because it transitively enabled the implicit `tracing` feature, but enabling `tracing` directly produced confusing partial behavior / compile errors (as reported in the issue). ### Changes - `amqprs/Cargo.toml`: `traces = ["tracing"]` → `traces = ["dep:tracing"]`. This removes the implicit `tracing` feature entirely. MSRV 1.71 supports the `dep:` syntax. - `amqprs/src/net/writer_handler.rs`: 5 stale `#[cfg(feature="tracing")]` → `#[cfg(feature = "traces")]`. - `amqprs/tests/test_get.rs`: 2 stale `#[cfg(feature = "tracing")]` → `#[cfg(feature = "traces")]`. After this change, accidentally enabling the old implicit feature produces a clear error: ``` error: the package 'amqprs' does not contain this feature: tracing help: there is a similarly named feature: traces ``` ## Test plan - [x] `cargo build -p amqprs` (default features) - [x] `cargo build -p amqprs --features traces` - [x] `cargo build --all-features` - [x] `cargo clippy --all-features -- -Dwarnings` - [x] `cargo test --no-run -p amqprs` (default and `--features traces`) - [x] Verified `cargo build -p amqprs --features tracing` now fails with a helpful error. --- _Generated by [Claude Code](https://claude.ai/code/session_01KMFWS54Y6Wf9hq1MjUW999)_
合并状态:未合并 关闭于 2026-05-24 1 条评论