mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-25 10:48:39 +00:00
Support Rust edition 2024 (#8638)
* Developers intro how to contribute * Fix Rust code generation for Rust edition 2024 The errors look like: ``` warning[E0133]: call to unsafe function `fbs::flatbuffers::emplace_scalar` is unsafe and requires unsafe block warning[E0133]: call to unsafe function `fbs::flatbuffers::follow_cast_ref` is unsafe and requires unsafe block warning[E0133]: call to unsafe function `fbs::flatbuffers::Follow::follow` is unsafe and requires unsafe block warning[E0133]: call to unsafe function `fbs::flatbuffers::read_scalar_at` is unsafe and requires unsafe block warning[E0133]: call to unsafe function `fbs::flatbuffers::root_unchecked` is unsafe and requires unsafe block warning[E0133]: call to unsafe function `fbs::flatbuffers::size_prefixed_root_unchecked` is unsafe and requires unsafe block warning[E0133]: call to unsafe function `fbs::flatbuffers::Table::<'a>::new` is unsafe and requires unsafe block warning[E0133]: call to unsafe function `std::slice::from_raw_parts` is unsafe and requires unsafe block ``` * Update goldens Ran `goldens/generate_goldens.py` * Regenerate code files Ran `scripts/generate_code.py`
This commit is contained in:
@@ -37,7 +37,7 @@ impl<'a> flatbuffers::Follow<'a> for Galaxy<'a> {
|
||||
type Inner = Galaxy<'a>;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table::new(buf, loc) }
|
||||
Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ impl<'a> flatbuffers::Follow<'a> for Universe<'a> {
|
||||
type Inner = Universe<'a>;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table::new(buf, loc) }
|
||||
Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,14 +288,14 @@ pub fn size_prefixed_root_as_universe_with_opts<'b, 'o>(
|
||||
/// # Safety
|
||||
/// Callers must trust the given bytes do indeed contain a valid `Universe`.
|
||||
pub unsafe fn root_as_universe_unchecked(buf: &[u8]) -> Universe {
|
||||
flatbuffers::root_unchecked::<Universe>(buf)
|
||||
unsafe { flatbuffers::root_unchecked::<Universe>(buf) }
|
||||
}
|
||||
#[inline]
|
||||
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Universe and returns it.
|
||||
/// # Safety
|
||||
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Universe`.
|
||||
pub unsafe fn size_prefixed_root_as_universe_unchecked(buf: &[u8]) -> Universe {
|
||||
flatbuffers::size_prefixed_root_unchecked::<Universe>(buf)
|
||||
unsafe { flatbuffers::size_prefixed_root_unchecked::<Universe>(buf) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn finish_universe_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
|
||||
|
||||
Reference in New Issue
Block a user