Santiago Medina created THRIFT-6059:
---------------------------------------

             Summary: Rust codegen: add crate_prefix option for cross-file 
import path
                 Key: THRIFT-6059
                 URL: https://issues.apache.org/jira/browse/THRIFT-6059
             Project: Thrift
          Issue Type: Bug
            Reporter: Santiago Medina


The Rust code generator hardcodes use crate:: when one .thrift file includes 
another (e.g., event.thrift includes trees.thrift → generates use 
crate::trees;). This assumes the generated files are placed directly under the 
crate root (src/). When generated files are placed in a submodule (e.g., 
src/thrift/), the correct import is use super::trees;, and users must manually 
post-process the generated files with sed to fix the paths.

This patch adds a crate_prefix generator option that controls the path prefix. 
The default remains crate for backward compatibility. Users generating into a 
submodule can pass --gen rs:crate_prefix=super to produce correct imports 
without post-processing.

Usage:

# Files at crate root (src/) — existing behavior, unchanged
thrift --gen rs -out src/ schema.thrift

# Files in a submodule (src/thrift/) — new option
thrift --gen rs:crate_prefix=super -out src/thrift/ schema.thrift



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to