Skip to content

Comments

chore: gate http import behind feature#59

Merged
Nugine merged 2 commits intoNugine:mainfrom
Ocheretovich:main
Jan 20, 2026
Merged

chore: gate http import behind feature#59
Nugine merged 2 commits intoNugine:mainfrom
Ocheretovich:main

Conversation

@Ocheretovich
Copy link
Contributor

Guards http::header::HeaderName import behind the http feature flag to avoid pulling the dependency when the feature is disabled

@codecov
Copy link

codecov bot commented Jan 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.86%. Comparing base (f66b69d) to head (a59b999).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 http from dev-dependencies to optional dependencies
  • Updated the http feature flag to include dep:http, properly gating the dependency

@Nugine
Copy link
Owner

Nugine commented Jan 18, 2026

pulling the dependency when the feature is disabled

The dep path is const-str -> const-str-proc-macro -> http (main branch). I guess it should not happen. Is there any reproduction?

/// Returns a compile-time verified header name string literal.
#[cfg(feature = "http")]
#[proc_macro]
pub fn verified_header_name(input: TokenStream) -> TokenStream {
use http::header::HeaderName;
direct_convert(input, |s: &LitStr| {
let s = s.value();
HeaderName::from_lowercase(s.as_bytes()).map(|_| s)
})
}

Copy link
Owner

@Nugine Nugine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pulling the dependency when the feature is disabled

The original problem described in this PR needs reproduction.

@Ocheretovich
Copy link
Contributor Author

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
cargo build -p const-str --no-default-features
cargo tree -p const-str

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

@Nugine
Copy link
Owner

Nugine commented Jan 19, 2026

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.

@Nugine Nugine merged commit 35e1034 into Nugine:main Jan 20, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants