current_fn_name: String is set at the start of visit_function_definition and read inside lower_sret_return. This is an ambient context — a value implicitly available rather than explicitly threaded through the call chain. Industrial compilers (rustc, LLVM, Zig) thread function context explicitly via a FnCtxt or parameter.
Currently tolerable because it is only read in one place (lower_sret_return), and the data flow is clear: visit_function_definition → lower_statement → lower_sret_return.
- Fix: Thread
fn_name: &str as a parameter, or fold it into a LoweringContext struct alongside frame_layout, locals_map, and other per-function state.
-
- Trigger: When adding method compilation, incremental compilation, or parallel function compilation.
current_fn_name: Stringis set at the start ofvisit_function_definitionand read insidelower_sret_return. This is an ambient context — a value implicitly available rather than explicitly threaded through the call chain. Industrial compilers (rustc, LLVM, Zig) thread function context explicitly via aFnCtxtor parameter.Currently tolerable because it is only read in one place (
lower_sret_return), and the data flow is clear:visit_function_definition→lower_statement→lower_sret_return.fn_name: &stras a parameter, or fold it into aLoweringContextstruct alongsideframe_layout,locals_map, and other per-function state.