transpile: hoist function-local statics to the root of the current module - #1983
Open
ahomescu wants to merge 2 commits into
Open
transpile: hoist function-local statics to the root of the current module#1983ahomescu wants to merge 2 commits into
ahomescu wants to merge 2 commits into
Conversation
Contributor
Author
|
Here is the new Rust output for the test at the top level of static mut rust_local_static_arr: [::core::ffi::c_int; 3] = [
1 as ::core::ffi::c_int,
2 as ::core::ffi::c_int,
3 as ::core::ffi::c_int,
];
static mut rust_local_static_s: [slice_ref; 1] = [slice_ref {
p: ::core::ptr::null::<::core::ffi::c_int>(),
len: 0,
}; 1];
static mut rust_chain_a: [::core::ffi::c_int; 3] = [
5 as ::core::ffi::c_int,
6 as ::core::ffi::c_int,
7 as ::core::ffi::c_int,
];
static mut rust_chain_b: *mut ::core::ffi::c_int =
unsafe { &raw const rust_chain_a as *mut ::core::ffi::c_int };
static mut rust_chain_c: *mut *mut ::core::ffi::c_int =
::core::ptr::null_mut::<*mut ::core::ffi::c_int>(); |
ahomescu
force-pushed
the
ahomescu/hoist_static_initializers
branch
from
August 25, 2026 03:00
f954554 to
b975698
Compare
Contributor
|
Could the test here also exercise the renamer by including multiple functions with distinct, identically-named |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Function-local statics with "uncompilable" initializers are referenced from
c2rust_run_static_initializersbut previously emitted inside the owner function. Hoist them to the top of the current module soc2rust_run_static_initializerscan reference them by name. Example from issue #1981:Here
local_static_sandlocal_static_arr(because the former references it) need to be moved out ofmain.Fixes issue #1981.