BaldDemian opened a new issue, #3730: URL: https://github.com/apache/fory/issues/3730
### Search before asking - [x] I had searched in the [issues](https://github.com/apache/fory/issues) and found no similar issues. ### Version Fory: latest OS: Ubuntu 24.04.3 GCC: 11.5.0 ### Component(s) Rust ### Minimal reproduce step Run this testcase: ```python def test_rust_nested_list_ref_uses_container_local_pointer_type(): schema = parse_fdl( dedent( """ package gen; message Node { string value = 1; } message Request { list<list<ref(thread_safe=true) Node>> groups = 1; } """ ) ) rust_output = render_files(generate_files(schema, RustGenerator)) assert "pub groups: ::std::vec::Vec<::std::vec::Vec<::std::sync::Arc<Node>>>," in rust_output assert "::std::vec::Vec<::std::vec::Vec<::std::rc::Rc<Node>>>" not in rust_output ``` ### What did you expect to see? The testcase should pass, i.e. `groups` should be compiled into `::std::vec::Vec<::std::vec::Vec<::std::sync::Arc<Node>>>`, not `::std::vec::Vec<::std::vec::Vec<::std::rc::Rc<Node>>>`. ### What did you see instead? The testcase failed. ### Anything Else? The Rust compiler does not correctly apply ref pointer options for **nested** container element/value references. The same issue can affect nested map value references, such as `map<string, map<string, ref(thread_safe=true) Node>>`. The root cause is that `RustGenerator.generate_type` receives a single `pointer_type` argument computed once from the outer `Field` by `get_field_pointer_type(field)`: https://github.com/apache/fory/blob/810943c24db7866bf4e57960c2fd8a3c1e4329fe/compiler/fory_compiler/generators/rust.py#L909-L918 That pointer type is then recursively reused for nested container types. When recursion reaches a nested `ListType.element_ref` or `MapType.value_ref`, the generator does not recompute the pointer type from the nested container's own `element_ref_options` or `value_ref_options`. As a result, nested `ref(thread_safe=true)` metadata is ignored and the default pointer type `Rc` is used instead of `Arc`. ### Are you willing to submit a PR? - [x] I'm willing to submit a PR! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
