Skip to content

Fix/num traits peer dependency#87

Open
piliugin-anton wants to merge 2 commits intocodama-idl:mainfrom
piliugin-anton:fix/num-traits-peer-dependency
Open

Fix/num traits peer dependency#87
piliugin-anton wants to merge 2 commits intocodama-idl:mainfrom
piliugin-anton:fix/num-traits-peer-dependency

Conversation

@piliugin-anton
Copy link

fix: include num-traits in Cargo.toml when num-derive is used

Problem

When syncCargoToml: true, the generated Cargo.toml includes num-derive but not num-traits, causing error[E0463]: can't find crate for num_traits. Although num-traits is listed in DEFAULT_DEPENDENCY_VERSIONS, that map is only a version lookup table — a dependency only gets added to Cargo.toml if it's first detected as "used" by scanning rendered source for crate references. The scanner correctly finds num_derive from #[derive(num_derive::FromPrimitive)] in generated code, but num_traits never appears in source — it's only referenced inside the proc-macro expansion that rustc produces at compile time. Since the scanner never sees num_traits, it's never looked up in DEFAULT_DEPENDENCY_VERSIONS and never written to Cargo.toml.

Fix

Adds a PEER_DEPENDENCIES map that declares runtime crates required by proc-macro crates (num-derivenum-traits). After the initial import scan in getUsedDependencyVersions(), a new expandPeerDependencies() step adds any missing peers, respecting user-provided version overrides and routing unresolvable peers through the existing error path.

@changeset-bot
Copy link

changeset-bot bot commented Feb 23, 2026

🦋 Changeset detected

Latest commit: 676d1e5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@codama/renderers-rust Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

1 participant