Skip to content

message_len is declared const fn but calls non-const functions, causing E0015 build failures #586

@OleFass

Description

@OleFass

After upgrading from yellowstone-grpc-proto = 5.1.0 to yellowstone-grpc-proto = 6.1.0 the build fails with:

error[E0015]: cannot call non-const fn `key_len` in constant functions
  ...
  key_len(tag) + encoded_len_varint(len as u64) + len
  ^^^^^^^^^^^^
error[E0015]: cannot call non-const fn `encoded_len_varint` in constant functions
  ...
  key_len(tag) + encoded_len_varint(len as u64) + len
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The generated message_len in
src/plugin/filter/message.rs:40 is declared pub const fn, but it invokes encoded_len_varint, which is not a const fn. Rust rejects any non-const calls inside a const fn (E0015).

Reproduction:

Add yellowstone-grpc-proto = "6.1.0" to your Cargo.toml.

Run cargo build.

Observe the two E0015 errors above.

Expected behavior:
Codegen should either:

Declare message_len as a plain fn (remove const)

Either change would allow downstream crates to compile without patching or downgrading.

Environment:

rustc 1.84.0 (stable)
yellowstone-grpc-proto 6.1.0

Suggested fix:
In src/plugin/filter/message.rs, change:

-pub const fn message_len(tag: u32, len: usize) -> usize {
+pub fn message_len(tag: u32, len: usize) -> usize {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions