fix(idl_gen_rust): Fix lifetime warning added in Rust 1.89 (#8709)

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

The Rust code generator currently emits code which trips this warning. This very small PR
fixes the issue for the relevant generated functions and for the Rust flexbuffers code.

Fixes #8705
This commit is contained in:
Rob Jellinghaus
2025-12-02 19:27:40 -08:00
committed by GitHub
parent 4786322b90
commit a5343d6116
9 changed files with 32 additions and 32 deletions

View File

@@ -407,7 +407,7 @@ impl MonsterT {
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `root_as_monster_unchecked`.
pub fn root_as_monster(buf: &[u8]) -> Result<Monster, flatbuffers::InvalidFlatbuffer> {
pub fn root_as_monster(buf: &[u8]) -> Result<Monster<'_>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::root::<Monster>(buf)
}
#[inline]
@@ -417,7 +417,7 @@ pub fn root_as_monster(buf: &[u8]) -> Result<Monster, flatbuffers::InvalidFlatbu
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `size_prefixed_root_as_monster_unchecked`.
pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result<Monster, flatbuffers::InvalidFlatbuffer> {
pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result<Monster<'_>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::size_prefixed_root::<Monster>(buf)
}
#[inline]
@@ -450,14 +450,14 @@ pub fn size_prefixed_root_as_monster_with_opts<'b, 'o>(
/// Assumes, without verification, that a buffer of bytes contains a Monster and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `Monster`.
pub unsafe fn root_as_monster_unchecked(buf: &[u8]) -> Monster {
pub unsafe fn root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
unsafe { flatbuffers::root_unchecked::<Monster>(buf) }
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Monster and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Monster`.
pub unsafe fn size_prefixed_root_as_monster_unchecked(buf: &[u8]) -> Monster {
pub unsafe fn size_prefixed_root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
unsafe { flatbuffers::size_prefixed_root_unchecked::<Monster>(buf) }
}
#[inline]