(`c2rust transpile`) Translate `static const`s without raw ptrs as non-`mut` `static`s
Maintainers usually reply within 7 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 65/100
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from immunant/c2rust
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 7 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 7 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
immunant/c2rust#621 · 2 comments · 1 reaction ·
Maintainers usually reply within 7 days
-
reorganize_definitions breaks SQLite when the CLI shell and its extensions are includedPossibly taken @thedataking claimed this 6 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 22/100
Maintainers usually reply within 7 days
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Maintainers usually reply within 7 days
Similar issues
-
llm translation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
BerriAI/litellm#47884 · 1 comment ·
Maintainers usually reply within 1 day
-
bug(stubgen): `typing` / `_typeshed` imports are emitted above `from __future__ import annotations`Openstubgen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
bug-hunt confirmed good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
area: pcb area: rendering priority: high status: needs-triage type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
rustls/rustls-platform-verifier#262 · 2 comments · 2 reactions ·