Skip to content

[Rust] flatbuffers Rust codegen trips new lifetime lint in Rust 1.89 #8705

@RobJellinghaus

Description

@RobJellinghaus

Rust 1.89 added a new lifetime-related lint: https://blog.rust-lang.org/2025/08/07/Rust-1.89.0/#mismatched-lifetime-syntaxes-lint

The current flatbuffers generated code trips this warning (private function/type names redacted):

warning: hiding a lifetime that's elided elsewhere is confusing
   --> /home/redacted/target/debug/build/redacted-7d5c194b485ae547/out/fb/redacted_generated.rs:833:52
    |
833 | pub unsafe fn root_as_xxxxx_xxxxxxx_unchecked(buf: &[u8]) -> XxxxxXxxxxxx {
    |                                                    ^^^^^     ------------ the same lifetime is hidden here
    |                                                    |
    |                                                    the lifetime is elided here
    |
    = help: the same lifetime is referred to in inconsistent ways, making the signature confusing
help: use `'_` for type paths
    |
833 | pub unsafe fn root_as_xxxxx_xxxxxxx_unchecked(buf: &[u8]) -> XxxxxXxxxxxx<'_> {
    |                                                                          ++++

The workaround is to add #[expect(mismatched_lifetime_syntaxes)] or #![expect(mismatched_lifetime_syntaxes)] in the build.rs script which runs the flatbuffers Rust code generation.

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