Skip to content

Fix invalid Rust identifiers generated from symbol names - #21

Draft
KakarottoCake wants to merge 1 commit into
KaiserGranatapfel:mainfrom
KakarottoCake:upstream/codegen-identifiers
Draft

Fix invalid Rust identifiers generated from symbol names#21
KakarottoCake wants to merge 1 commit into
KaiserGranatapfel:mainfrom
KakarottoCake:upstream/codegen-identifiers

Conversation

@KakarottoCake

@KakarottoCake KakarottoCake commented Jul 29, 2026

Copy link
Copy Markdown

Description

Generated function names can fail to compile when a source symbol becomes empty after sanitization or begins with a digit. This change gives empty results a neutral fallback and prefixes digit-leading results so the generated Rust identifier has a valid start.

Existing valid identifiers and the current punctuation normalization remain unchanged.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring
  • Test addition/update

Related Issues

No linked issue.

Changes Made

  • Return function when sanitization would otherwise produce an empty string.
  • Prefix sanitized identifiers that begin with a number with function_.
  • Add focused regression coverage for empty input, leading digits, punctuation, punctuation-only input, and an already-valid identifier.

Testing

  • cargo fmt --all -- --check — passed locally and on Ubuntu stable.
  • cargo test -p gcrecomp-core — passed on Ubuntu stable: 23 tests across four test binaries, 0 failed.
  • cargo clippy -p gcrecomp-core --all-targets --all-features -- -D warnings — passed on Ubuntu stable.
  • git diff --check upstream/main...HEAD — passed locally.
  • Complete diff reviewed against upstream/main; only the sanitizer and focused codegen tests are changed.

Remote validation: focused CI run. Upstream's own CI is waiting for the repository's first-time-contributor workflow approval; GitHub reports action_required, not a test failure. Local Rust test/clippy execution was blocked because this Windows shell resolves DevkitPro's Unix link.exe instead of the Microsoft linker, so the package checks were run in the clean Ubuntu stable workflow above.

Checklist

  • My code follows the project's code style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (not needed; no public API change)
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (passed in the clean CI environment; local linker limitation documented above)
  • Any dependent changes have been merged and published (none)
  • I have read the EULA and CONTRIBUTING.md
  • My contribution complies with clean-room reverse engineering principles
  • I have not included any proprietary Nintendo code, SDKs, or copyrighted assets

Additional Notes

The fixtures are entirely synthetic and the branch is based directly on the current upstream/main (d380537).

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