chore: gate http import behind feature#59
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #59 +/- ##
=======================================
Coverage 94.86% 94.86%
=======================================
Files 37 37
Lines 3855 3855
Branches 3855 3855
=======================================
Hits 3657 3657
Misses 171 171
Partials 27 27 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR ensures the http dependency is only pulled in when the http feature is explicitly enabled, reducing unnecessary dependencies for users who don't need HTTP header validation functionality.
Changes:
- Moved
httpfrom dev-dependencies to optional dependencies - Updated the
httpfeature flag to includedep:http, properly gating the dependency
The dep path is const-str/crates/const-str-proc-macro/src/lib.rs Lines 64 to 74 in f66b69d |
Nugine
left a comment
There was a problem hiding this comment.
pulling the dependency when the feature is disabled
The original problem described in this PR needs reproduction.
|
I can reproduce the original issue on main by running: cargo tree -p const-str which shows http pulled via const-str -> const-str-proc-macro -> http. After this change, with features disabled: cargo clean http is no longer present in the dependency graph. The proc-macro side is gated via cfg(feature = "http") and the root crate feature now explicitly includes dep:http, so the dependency should only be pulled when --features http is enabled |
|
The optional dev-dependencies problem: rust-lang/cargo#1596 So the fix looks reasonable. You can also change the other dev-dependencies. The fix does not affect downstream users. |
Guards http::header::HeaderName import behind the http feature flag to avoid pulling the dependency when the feature is disabled