Skip to content

fix(pilota-build): incorrect merge function signature for cycled-enum#360

Open
shenyj3 wants to merge 3 commits intomainfrom
bugfix/cycled-enum-merge-sig-error
Open

fix(pilota-build): incorrect merge function signature for cycled-enum#360
shenyj3 wants to merge 3 commits intomainfrom
bugfix/cycled-enum-merge-sig-error

Conversation

@shenyj3
Copy link

@shenyj3 shenyj3 commented Mar 5, 2026

Motivation

Fix the compile error of the pb generated code caused by nested enum.

For nested enum, pilota-build will use ::std::option::Option and ::std::boxed::Box to wrap the real enum type in struct field declaration. But the merge method of the enum type only accept ::std::option::Option<Self>.

error[E0308]: mismatched types
   --> /data00/home/shenyuji/tmp/rust-test/target/debug/build/pb-gen-229d3f2befcfa45d/out/pb_gen.rs:37:37
    |
 37 |                         a::B::merge(&mut _inner_pilota_value, tag, wire_type, buf, ctx).map_err(
    |                         ----------- ^^^^^^^^^^^^^^^^^^^^^^^^ expected `&mut Option<B>`, found `&mut &mut Option<Box<B>>`
    |                         |
    |                         arguments to this function are incorrect
    |
    = note: expected mutable reference `&mut std::option::Option<B>`
               found mutable reference `&mut &mut std::option::Option<Box<B>>`
note: associated function defined here
   --> /data00/home/shenyuji/tmp/rust-test/target/debug/build/pb-gen-229d3f2befcfa45d/out/pb_gen.rs:662:24
    |
662 |                 pub fn merge(
    |                        ^^^^^
663 |                     field: &mut ::core::option::Option<Self>,
    |                     ----------------------------------------

Solution

Change the type of the first param of the nested-enum merge method from &mut Option<Self> to &mut Option<Box<T>>.

@shenyj3 shenyj3 requested review from a team as code owners March 5, 2026 07:26
@codecov
Copy link

codecov bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.59%. Comparing base (67eb3ec) to head (b414ff1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #360      +/-   ##
==========================================
+ Coverage   66.37%   66.59%   +0.22%     
==========================================
  Files          88       88              
  Lines       24577    24710     +133     
==========================================
+ Hits        16312    16456     +144     
+ Misses       8265     8254      -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@PureWhiteWu
Copy link
Member

@cursor run

@cursor
Copy link

cursor bot commented Mar 5, 2026

我已检查 pilota-build/src/codegen/pb/mod.rs,目前针对 cycled enummerge 签名已经是 &mut Option<Box<Self>>,并且对应的分支逻辑与 Box 使用一致,这与 PR 描述的修复点一致。因此当前分支没有需要再修改的代码。
测试未运行(如果需要我执行某个测试/复现流程,请给出具体命令或用例)。

Open in Web Open in Cursor 

@shenyj3
Copy link
Author

shenyj3 commented Mar 5, 2026

@cursor run

known issue, already fix in another pr.

let me cherry-pick to this pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants