Skip to content

Fix: round trip name conversions on resources are not stable#1112

Merged
gbin merged 6 commits into
masterfrom
gbin/resources-casing
May 25, 2026
Merged

Fix: round trip name conversions on resources are not stable#1112
gbin merged 6 commits into
masterfrom
gbin/resources-casing

Conversation

@gbin
Copy link
Copy Markdown
Collaborator

@gbin gbin commented May 20, 2026

The root cause was an asymmetric name conversion in the derive path. Resource bundle slots are written in config as strings like
linux.i2c1, but the runtime macro was reconstructing a Rust enum variant name from that string in core/cu29_derive/src/
lib.rs:7115. For i2c1, that conversion produced I2C1, while cu_linux_resources declared the bundle variant as I2c1 in components/
res/cu_linux_resources/src/lib.rs:314. So the macro emitted LinuxResourcesId::I2C1, which does not exist.

I fixed it by making resource resolution use the bundle’s declared slot names instead of guessing variant casing. The new lookup
lives in core/cu29_runtime/src/resource.rs:161, bundle_resources! now carries canonical names in core/cu29_derive/src/
bundle_resources.rs:8, and cu_linux_resources now explicitly declares i2c0..2 as slot names in components/res/cu_linux_resources/
src/lib.rs:314. I also added a regression test for the exact i2c1 case in core/cu29_derive/tests/compile_pass/copper_runtime/
resource_bundle_slot_name_case.rs:1.

Summary

Related issues

Changes

Reminder

  • I ran just from the repo root
  • I have updated docs or examples where needed

Additional context

gbin added 5 commits May 20, 2026 05:00
The root cause was an asymmetric name conversion in the derive path. Resource bundle slots are written in config as strings like
  linux.i2c1, but the runtime macro was reconstructing a Rust enum variant name from that string in core/cu29_derive/src/
  lib.rs:7115. For i2c1, that conversion produced I2C1, while cu_linux_resources declared the bundle variant as I2c1 in components/
  res/cu_linux_resources/src/lib.rs:314. So the macro emitted LinuxResourcesId::I2C1, which does not exist.

  I fixed it by making resource resolution use the bundle’s declared slot names instead of guessing variant casing. The new lookup
  lives in core/cu29_runtime/src/resource.rs:161, bundle_resources! now carries canonical names in core/cu29_derive/src/
  bundle_resources.rs:8, and cu_linux_resources now explicitly declares i2c0..2 as slot names in components/res/cu_linux_resources/
  src/lib.rs:314. I also added a regression test for the exact i2c1 case in core/cu29_derive/tests/compile_pass/copper_runtime/
  resource_bundle_slot_name_case.rs:1.
@gbin gbin requested a review from elpiel May 25, 2026 13:45
@gbin gbin changed the title Round trip name conversions on resources are not stable Fix: round trip name conversions on resources are not stable May 25, 2026
@gbin gbin merged commit 1f66a74 into master May 25, 2026
30 checks passed
@gbin gbin deleted the gbin/resources-casing branch May 25, 2026 16:23
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.

bug: Derive macro casing messes with cu_linux_resources

1 participant