fix(stageleft_tool): include strong-ref-enabled and target-specific deps in __deps#89
Draft
shadaj wants to merge 1 commit into
Draft
fix(stageleft_tool): include strong-ref-enabled and target-specific deps in __deps#89shadaj wants to merge 1 commit into
__deps#89shadaj wants to merge 1 commit into
Conversation
shadaj
added a commit
that referenced
this pull request
Jul 14, 2026
…eps in `__deps` Completes the fix for #62. PR #65 made optional dependencies show up in `__deps` behind `#[cfg(any(feature = ...))]` gates, but three gaps remained (the first two are hit by real manifests such as hydro_lang's): 1. Strong `pkg/feature` references were not treated as enabling an optional dependency. Cargo's `feat = ["tokio-stream/sync"]` enables the optional dep `tokio-stream`, but `optional_dep_features` only matched `dep:<name>` refs, so the re-export was cfg'd out when the dep was enabled solely via a strong ref. The old `dep:<name>/...` prefix check was dead code (not valid Cargo syntax) and has been removed. Weak `pkg?/feature` refs correctly do not count as gating. The implicit feature is now appended only when no `dep:<name>` reference exists anywhere (matching Cargo semantics). 2. `[target.'cfg(...)'.dependencies]` tables were ignored entirely, so target-specific deps (e.g. hydro_lang's linux-only `procfs`) never appeared in `__deps`. They are now collected and gated on the target's cfg predicate, composed with feature gates for optional deps: `#[cfg(all(<target cfg>, any(feature = ...)))]`. A dep declared in multiple tables is re-exported once, gated by `any()` of its per-declaration predicates, or ungated if any declaration is unconditional. Non-`cfg(...)` target keys (plain target triples) are skipped with a `cargo::warning` since they cannot be expressed as a cfg gate. 3. A missing `[dependencies]` table no longer panics. Implementation: `gen_deps_module` now builds a list of `Dep` entries (name, package alias, `Vec<DepDeclaration>`) collected from the main and target dependency tables via `collect_deps_from_table`, and `cfg_attr_for_declarations` derives the combined `#[cfg(...)]` attribute used for both the `pub use` re-exports and the runtime `add_deps_reexport` registrations. Tests: - 7 new unit tests in stageleft_tool covering strong refs, weak refs, target-specific deps (plain and optional), deps declared in both the main and target tables, deps in multiple target tables, and a manifest with no `[dependencies]` table. - stageleft_test_no_entry now declares `my_strong_ref_feature` (strong `once_cell/std` ref), `my_weak_ref_feature` (weak `once_cell?/std` ref), and a `[target.'cfg(unix)'.dependencies]` libc dep; the codegen snapshot shows the new gating, e.g. `#[cfg(any(feature = "my_strong_ref_feature", feature = "once_cell"))]` and `#[cfg(unix)] pub use libc;`. Note: the snapshot must be regenerated with a full workspace build (`cargo test --workspace --all-targets`, as CI does) — building the crate alone changes prettyplease's output formatting due to feature unification of syn's `full` feature. Verified with `cargo test --workspace --all-targets` (61 tests pass), `cargo fmt --all -- --check`, and `cargo clippy --all-targets -- -D warnings`. Co-authored-by: Infinity 🤖 <infinity@hydro.run> PR: #89
shadaj
force-pushed
the
sandbox-4517617e-08a9-45d6-8f6b-97b5c2591389
branch
from
July 14, 2026 22:33
5786583 to
b4711fe
Compare
…eps in `__deps` Completes the fix for #62. PR #65 made optional dependencies show up in `__deps` behind `#[cfg(any(feature = ...))]` gates, but three gaps remained (the first two are hit by real manifests such as hydro_lang's): 1. Strong `pkg/feature` references were not treated as enabling an optional dependency. Cargo's `feat = ["tokio-stream/sync"]` enables the optional dep `tokio-stream`, but `optional_dep_features` only matched `dep:<name>` refs, so the re-export was cfg'd out when the dep was enabled solely via a strong ref. The old `dep:<name>/...` prefix check was dead code (not valid Cargo syntax) and has been removed. Weak `pkg?/feature` refs correctly do not count as gating. The implicit feature is now appended only when no `dep:<name>` reference exists anywhere (matching Cargo semantics). 2. `[target.'cfg(...)'.dependencies]` tables were ignored entirely, so target-specific deps (e.g. hydro_lang's linux-only `procfs`) never appeared in `__deps`. They are now collected and gated on the target's cfg predicate, composed with feature gates for optional deps: `#[cfg(all(<target cfg>, any(feature = ...)))]`. A dep declared in multiple tables is re-exported once, gated by `any()` of its per-declaration predicates, or ungated if any declaration is unconditional. Non-`cfg(...)` target keys (plain target triples) are skipped with a `cargo::warning` since they cannot be expressed as a cfg gate. 3. A missing `[dependencies]` table no longer panics. Implementation: `gen_deps_module` now builds a list of `Dep` entries (name, package alias, `Vec<DepDeclaration>`) collected from the main and target dependency tables via `collect_deps_from_table`, and `cfg_attr_for_declarations` derives the combined `#[cfg(...)]` attribute used for both the `pub use` re-exports and the runtime `add_deps_reexport` registrations. Tests: - 7 new unit tests in stageleft_tool covering strong refs, weak refs, target-specific deps (plain and optional), deps declared in both the main and target tables, deps in multiple target tables, and a manifest with no `[dependencies]` table. - stageleft_test_no_entry now declares `my_strong_ref_feature` (strong `once_cell/std` ref), `my_weak_ref_feature` (weak `once_cell?/std` ref), and a `[target.'cfg(unix)'.dependencies]` libc dep; the codegen snapshot shows the new gating, e.g. `#[cfg(any(feature = "my_strong_ref_feature", feature = "once_cell"))]` and `#[cfg(unix)] pub use libc;`. Note: the snapshot must be regenerated with a full workspace build (`cargo test --workspace --all-targets`, as CI does) — building the crate alone changes prettyplease's output formatting due to feature unification of syn's `full` feature. Verified with `cargo test --workspace --all-targets` (61 tests pass), `cargo fmt --all -- --check`, and `cargo clippy --all-targets -- -D warnings`. Co-authored-by: Infinity 🤖 <infinity@hydro.run> PR: #89
shadaj
force-pushed
the
sandbox-4517617e-08a9-45d6-8f6b-97b5c2591389
branch
from
July 14, 2026 22:33
b4711fe to
4a38951
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes the fix for #62. PR #65 made optional
dependencies show up in
__depsbehind#[cfg(any(feature = ...))]gates, but three gaps remained (the first two are hit by real manifests
such as hydro_lang's):
Strong
pkg/featurereferences were not treated as enabling anoptional dependency. Cargo's
feat = ["tokio-stream/sync"]enablesthe optional dep
tokio-stream, butoptional_dep_featuresonlymatched
dep:<name>refs, so the re-export was cfg'd out when thedep was enabled solely via a strong ref. The old
dep:<name>/...prefix check was dead code (not valid Cargo syntax)and has been removed. Weak
pkg?/featurerefs correctly do notcount as gating. The implicit feature is now appended only when no
dep:<name>reference exists anywhere (matching Cargo semantics).[target.'cfg(...)'.dependencies]tables were ignored entirely, sotarget-specific deps (e.g. hydro_lang's linux-only
procfs) neverappeared in
__deps. They are now collected and gated on thetarget's cfg predicate, composed with feature gates for optional
deps:
#[cfg(all(<target cfg>, any(feature = ...)))]. A depdeclared in multiple tables is re-exported once, gated by
any()of its per-declaration predicates, or ungated if any declaration is
unconditional. Non-
cfg(...)target keys (plain target triples)are skipped with a
cargo::warningsince they cannot be expressedas a cfg gate.
A missing
[dependencies]table no longer panics.Implementation:
gen_deps_modulenow builds a list ofDepentries(name, package alias,
Vec<DepDeclaration>) collected from the mainand target dependency tables via
collect_deps_from_table, andcfg_attr_for_declarationsderives the combined#[cfg(...)]attribute used for both the
pub usere-exports and the runtimeadd_deps_reexportregistrations.Tests:
target-specific deps (plain and optional), deps declared in both the
main and target tables, deps in multiple target tables, and a
manifest with no
[dependencies]table.my_strong_ref_feature(strong
once_cell/stdref),my_weak_ref_feature(weakonce_cell?/stdref), and a[target.'cfg(unix)'.dependencies]libc dep; the codegen snapshot shows the new gating, e.g.
#[cfg(any(feature = "my_strong_ref_feature", feature = "once_cell"))]and
#[cfg(unix)] pub use libc;.Note: the snapshot must be regenerated with a full workspace build
(
cargo test --workspace --all-targets, as CI does) — building thecrate alone changes prettyplease's output formatting due to feature
unification of syn's
fullfeature.Verified with
cargo test --workspace --all-targets(61 tests pass),cargo fmt --all -- --check, andcargo clippy --all-targets -- -D warnings.