Skip to content

Disambiguate cluster block structs that collide with a child's accessor type - #978

Open
FarhanIslam17 wants to merge 6 commits into
rust-embedded:masterfrom
FarhanIslam17:fix-809-cluster-name-collision
Open

FarhanIslam17 wants to merge 6 commits into
rust-embedded:masterfrom
FarhanIslam17:fix-809-cluster-name-collision

Conversation

@FarhanIslam17

Copy link
Copy Markdown
Contributor

Fixes #809.

When a cluster contains a register (or cluster) with the same name - e.g. the psoc6 FM_CTL cluster containing an FM_CTL register - the cluster's register block struct and the child's accessor type share the cluster's module and collide: the generated code has both pub struct FmCtl and pub type FmCtl = Reg<fm_ctl::FmCtlSpec> and does not compile (E0428).

With this change the cluster's block struct is disambiguated by appending Cluster (e.g. FmCtlCluster) whenever a child's accessor type would get the same name. The register/cluster accessor keeps the plain name, and SVDs without such collisions are unaffected.

Verified:

  • The psoc63.svd from the issue now generates a flashc::fm_ctl module with the cluster struct renamed to FmCtlCluster and the register accessor kept as FmCtl, and the output compiles. On master the same SVD fails with the reported E0428.
  • A minimal repro (cluster FM_CTL containing register FM_CTL) compiles as well.
  • Regenerated atsamd21e18a (without cpu), ATSAMD21E15L, ATSAME70N21, ATSAM3S4B, ATSAM4S16B and R7FA6M3AH are byte-identical to master.
  • cargo fmt and cargo clippy clean (no new warnings).

@FarhanIslam17
FarhanIslam17 requested a review from a team as a code owner December 1, 2026 23:44

This branch has not been deployed

No deployments
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.

Error generating psoc6_pac

1 participant