You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by "Jens Geyer (Jira)" <ji...@apache.org> on 2026/07/04 21:09:00 UTC
[jira] [Updated] (THRIFT-6059) add crate_prefix option for cross-file import path
[ https://issues.apache.org/jira/browse/THRIFT-6059?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jens Geyer updated THRIFT-6059:
-------------------------------
Summary: add crate_prefix option for cross-file import path (was: Rust codegen: add crate_prefix option for cross-file import path)
> 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
> Components: Ruby - Compiler
> Reporter: Santiago Medina
> Assignee: Santiago Medina
> Priority: Major
> Fix For: 0.24.0
>
> Time Spent: 50m
> Remaining Estimate: 0h
>
> 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)