Commit 35c1a53
THRIFT-6059: add crate_prefix option to Rust codegen for cross-file imports
Client: rs
The Rust code generator hardcodes 'use crate::' for cross-file imports
(e.g., when event.thrift includes trees.thrift). This assumes the
generated files are placed at the crate root (src/). When files are
placed in a submodule (e.g., src/thrift/), the correct prefix is
'super', and users must post-process with sed.
Add a crate_prefix generator option: --gen rs:crate_prefix=super
Default remains 'crate' for backward compatibility. An empty value is
rejected since it would silently emit 'use ::module;' (an external
crate path in Rust 2018+). Unknown options are reported with the
generator prefix ('unknown option rs:') per compiler convention.
Co-Authored-By: Grok 4.3 <noreply@x.ai>1 parent 4b0691b commit 35c1a53
1 file changed
Lines changed: 29 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
57 | 59 | | |
58 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
59 | 74 | | |
60 | 75 | | |
61 | 76 | | |
| |||
91 | 106 | | |
92 | 107 | | |
93 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
94 | 113 | | |
95 | 114 | | |
96 | 115 | | |
| |||
617 | 636 | | |
618 | 637 | | |
619 | 638 | | |
620 | | - | |
| 639 | + | |
621 | 640 | | |
622 | | - | |
623 | | - | |
| 641 | + | |
| 642 | + | |
624 | 643 | | |
625 | 644 | | |
626 | 645 | | |
| |||
3397 | 3416 | | |
3398 | 3417 | | |
3399 | 3418 | | |
3400 | | - | |
| 3419 | + | |
| 3420 | + | |
| 3421 | + | |
| 3422 | + | |
| 3423 | + | |
| 3424 | + | |
0 commit comments