Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

(`c2rust transpile`) Translate `static const`s without raw ptrs as non-`mut` `static`s

Open Beginner friendly
#925 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 7 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
65/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
rust
Domain
compilers

Research direction

Find the code in the c2rust transpiler that generates Rust static items from C static declarations, likely in the code generation module. Update the logic to check if the C static is const and contains no raw pointers, then emit a non-mut static; otherwise keep using static mut. Run the test suite to confirm the change works correctly.

Written by the indexing model from the issue text.

Description

Currently, c2rust transpile translates all statics as static muts. This is still done even when the static in C is marked const. static muts are unsafe to access, so translating them as non-mut statics would be greatly beneficial. One caveat is that non-mut statics can't have any raw pointers anywhere inside them, so for those cases, we'll have to keep using a static mut, or possibly replace the raw pointers with Option<&'static _>s, as those raw pointers do have to be known at compile time. But at the very least, the simple static const cases with no raw pointers should be translated as non-mut statics. This would fix #907, as well as make manual transpilation like in rav1d easier (e.x. https://github.com/memorysafety/rav1d/pull/182/commits/27309d59cff90d889fa7338c3a69ccaad4c0dee4).

Dominant language
Rust
Stars
4.8k
Forks
318
Avg merge
7d 13h
Merged PRs (30d)
9

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from immunant/c2rust

All issues in immunant/c2rust

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.