Fixes unused imports in Rust code generator (#8828)

* Fixes unused imports in Rust code generator

* Regenerates generated schemas
This commit is contained in:
Cameron Mulhern
2025-12-05 00:59:47 -05:00
committed by GitHub
parent 5469bc9ef1
commit cfce38ec99
92 changed files with 3051 additions and 3771 deletions

View File

@@ -1,13 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
// @generated
extern crate alloc;
extern crate flatbuffers;
use alloc::boxed::Box;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use core::mem;
use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_ENUM_IN_NESTED_NS: i8 = 0;
@@ -47,8 +40,8 @@ impl EnumInNestedNS {
}
}
}
impl core::fmt::Debug for EnumInNestedNS {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
impl ::core::fmt::Debug for EnumInNestedNS {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
@@ -56,24 +49,24 @@ impl core::fmt::Debug for EnumInNestedNS {
}
}
}
impl<'a> flatbuffers::Follow<'a> for EnumInNestedNS {
impl<'a> ::flatbuffers::Follow<'a> for EnumInNestedNS {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { flatbuffers::read_scalar_at::<i8>(buf, loc) };
let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
Self(b)
}
}
impl flatbuffers::Push for EnumInNestedNS {
impl ::flatbuffers::Push for EnumInNestedNS {
type Output = EnumInNestedNS;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { flatbuffers::emplace_scalar::<i8>(dst, self.0); }
unsafe { ::flatbuffers::emplace_scalar::<i8>(dst, self.0) };
}
}
impl flatbuffers::EndianScalar for EnumInNestedNS {
impl ::flatbuffers::EndianScalar for EnumInNestedNS {
type Scalar = i8;
#[inline]
fn to_little_endian(self) -> i8 {
@@ -87,14 +80,13 @@ impl flatbuffers::EndianScalar for EnumInNestedNS {
}
}
impl<'a> flatbuffers::Verifiable for EnumInNestedNS {
impl<'a> ::flatbuffers::Verifiable for EnumInNestedNS {
#[inline]
fn run_verifier(
v: &mut flatbuffers::Verifier, pos: usize
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
use self::flatbuffers::Verifiable;
v: &mut ::flatbuffers::Verifier, pos: usize
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
i8::run_verifier(v, pos)
}
}
impl flatbuffers::SimpleToVerifyInSlice for EnumInNestedNS {}
impl ::flatbuffers::SimpleToVerifyInSlice for EnumInNestedNS {}

View File

@@ -1,13 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
// @generated
extern crate alloc;
extern crate flatbuffers;
use alloc::boxed::Box;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use core::mem;
use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
// struct StructInNestedNS, aligned to 4
#[repr(transparent)]
@@ -18,8 +11,8 @@ impl Default for StructInNestedNS {
Self([0; 8])
}
}
impl core::fmt::Debug for StructInNestedNS {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
impl ::core::fmt::Debug for StructInNestedNS {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
f.debug_struct("StructInNestedNS")
.field("a", &self.a())
.field("b", &self.b())
@@ -27,40 +20,39 @@ impl core::fmt::Debug for StructInNestedNS {
}
}
impl flatbuffers::SimpleToVerifyInSlice for StructInNestedNS {}
impl<'a> flatbuffers::Follow<'a> for StructInNestedNS {
impl ::flatbuffers::SimpleToVerifyInSlice for StructInNestedNS {}
impl<'a> ::flatbuffers::Follow<'a> for StructInNestedNS {
type Inner = &'a StructInNestedNS;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { <&'a StructInNestedNS>::follow(buf, loc) }
}
}
impl<'a> flatbuffers::Follow<'a> for &'a StructInNestedNS {
impl<'a> ::flatbuffers::Follow<'a> for &'a StructInNestedNS {
type Inner = &'a StructInNestedNS;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { flatbuffers::follow_cast_ref::<StructInNestedNS>(buf, loc) }
unsafe { ::flatbuffers::follow_cast_ref::<StructInNestedNS>(buf, loc) }
}
}
impl<'b> flatbuffers::Push for StructInNestedNS {
impl<'b> ::flatbuffers::Push for StructInNestedNS {
type Output = StructInNestedNS;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
let src = unsafe { ::core::slice::from_raw_parts(self as *const StructInNestedNS as *const u8, <Self as flatbuffers::Push>::size()) };
let src = unsafe { ::core::slice::from_raw_parts(self as *const StructInNestedNS as *const u8, <Self as ::flatbuffers::Push>::size()) };
dst.copy_from_slice(src);
}
#[inline]
fn alignment() -> flatbuffers::PushAlignment {
flatbuffers::PushAlignment::new(4)
fn alignment() -> ::flatbuffers::PushAlignment {
::flatbuffers::PushAlignment::new(4)
}
}
impl<'a> flatbuffers::Verifiable for StructInNestedNS {
impl<'a> ::flatbuffers::Verifiable for StructInNestedNS {
#[inline]
fn run_verifier(
v: &mut flatbuffers::Verifier, pos: usize
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
use self::flatbuffers::Verifiable;
v: &mut ::flatbuffers::Verifier, pos: usize
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
v.in_buffer::<Self>(pos)
}
}
@@ -82,59 +74,59 @@ impl<'a> StructInNestedNS {
}
pub fn a(&self) -> i32 {
let mut mem = core::mem::MaybeUninit::<<i32 as EndianScalar>::Scalar>::uninit();
let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
// Safety:
// Created from a valid Table for this object
// Which contains a valid value in this slot
EndianScalar::from_little_endian(unsafe {
core::ptr::copy_nonoverlapping(
::flatbuffers::EndianScalar::from_little_endian(unsafe {
::core::ptr::copy_nonoverlapping(
self.0[0..].as_ptr(),
mem.as_mut_ptr() as *mut u8,
core::mem::size_of::<<i32 as EndianScalar>::Scalar>(),
::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
);
mem.assume_init()
})
}
pub fn set_a(&mut self, x: i32) {
let x_le = x.to_little_endian();
let x_le = ::flatbuffers::EndianScalar::to_little_endian(x);
// Safety:
// Created from a valid Table for this object
// Which contains a valid value in this slot
unsafe {
core::ptr::copy_nonoverlapping(
::core::ptr::copy_nonoverlapping(
&x_le as *const _ as *const u8,
self.0[0..].as_mut_ptr(),
core::mem::size_of::<<i32 as EndianScalar>::Scalar>(),
::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
);
}
}
pub fn b(&self) -> i32 {
let mut mem = core::mem::MaybeUninit::<<i32 as EndianScalar>::Scalar>::uninit();
let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
// Safety:
// Created from a valid Table for this object
// Which contains a valid value in this slot
EndianScalar::from_little_endian(unsafe {
core::ptr::copy_nonoverlapping(
::flatbuffers::EndianScalar::from_little_endian(unsafe {
::core::ptr::copy_nonoverlapping(
self.0[4..].as_ptr(),
mem.as_mut_ptr() as *mut u8,
core::mem::size_of::<<i32 as EndianScalar>::Scalar>(),
::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
);
mem.assume_init()
})
}
pub fn set_b(&mut self, x: i32) {
let x_le = x.to_little_endian();
let x_le = ::flatbuffers::EndianScalar::to_little_endian(x);
// Safety:
// Created from a valid Table for this object
// Which contains a valid value in this slot
unsafe {
core::ptr::copy_nonoverlapping(
::core::ptr::copy_nonoverlapping(
&x_le as *const _ as *const u8,
self.0[4..].as_mut_ptr(),
core::mem::size_of::<<i32 as EndianScalar>::Scalar>(),
::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
);
}
}

View File

@@ -1,45 +1,38 @@
// automatically generated by the FlatBuffers compiler, do not modify
// @generated
extern crate alloc;
extern crate flatbuffers;
use alloc::boxed::Box;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use core::mem;
use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum TableInNestedNSOffset {}
#[derive(Copy, Clone, PartialEq)]
pub struct TableInNestedNS<'a> {
pub _tab: flatbuffers::Table<'a>,
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> flatbuffers::Follow<'a> for TableInNestedNS<'a> {
impl<'a> ::flatbuffers::Follow<'a> for TableInNestedNS<'a> {
type Inner = TableInNestedNS<'a>;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } }
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
}
}
impl<'a> TableInNestedNS<'a> {
pub const VT_FOO: flatbuffers::VOffsetT = 4;
pub const VT_FOO: ::flatbuffers::VOffsetT = 4;
pub const fn get_fully_qualified_name() -> &'static str {
"NamespaceA.NamespaceB.TableInNestedNS"
}
#[inline]
pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
TableInNestedNS { _tab: table }
}
#[allow(unused_mut)]
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
args: &'args TableInNestedNSArgs
) -> flatbuffers::WIPOffset<TableInNestedNS<'bldr>> {
) -> ::flatbuffers::WIPOffset<TableInNestedNS<'bldr>> {
let mut builder = TableInNestedNSBuilder::new(_fbb);
builder.add_foo(args.foo);
builder.finish()
@@ -61,12 +54,11 @@ impl<'a> TableInNestedNS<'a> {
}
}
impl flatbuffers::Verifiable for TableInNestedNS<'_> {
impl ::flatbuffers::Verifiable for TableInNestedNS<'_> {
#[inline]
fn run_verifier(
v: &mut flatbuffers::Verifier, pos: usize
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
use self::flatbuffers::Verifiable;
v: &mut ::flatbuffers::Verifier, pos: usize
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
v.visit_table(pos)?
.visit_field::<i32>("foo", Self::VT_FOO, false)?
.finish();
@@ -85,17 +77,17 @@ impl<'a> Default for TableInNestedNSArgs {
}
}
pub struct TableInNestedNSBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
pub struct TableInNestedNSBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TableInNestedNSBuilder<'a, 'b, A> {
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableInNestedNSBuilder<'a, 'b, A> {
#[inline]
pub fn add_foo(&mut self, foo: i32) {
self.fbb_.push_slot::<i32>(TableInNestedNS::VT_FOO, foo, 0);
}
#[inline]
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TableInNestedNSBuilder<'a, 'b, A> {
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableInNestedNSBuilder<'a, 'b, A> {
let start = _fbb.start_table();
TableInNestedNSBuilder {
fbb_: _fbb,
@@ -103,14 +95,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TableInNestedNSBuilder<'a, 'b,
}
}
#[inline]
pub fn finish(self) -> flatbuffers::WIPOffset<TableInNestedNS<'a>> {
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableInNestedNS<'a>> {
let o = self.fbb_.end_table(self.start_);
flatbuffers::WIPOffset::new(o.value())
::flatbuffers::WIPOffset::new(o.value())
}
}
impl core::fmt::Debug for TableInNestedNS<'_> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
impl ::core::fmt::Debug for TableInNestedNS<'_> {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
let mut ds = f.debug_struct("TableInNestedNS");
ds.field("foo", &self.foo());
ds.finish()
@@ -129,10 +121,10 @@ impl Default for TableInNestedNST {
}
}
impl TableInNestedNST {
pub fn pack<'b, A: flatbuffers::Allocator + 'b>(
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
_fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>
) -> flatbuffers::WIPOffset<TableInNestedNS<'b>> {
_fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
) -> ::flatbuffers::WIPOffset<TableInNestedNS<'b>> {
let foo = self.foo;
TableInNestedNS::create(_fbb, &TableInNestedNSArgs{
foo,

View File

@@ -1,13 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
// @generated
extern crate alloc;
extern crate flatbuffers;
use alloc::boxed::Box;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use core::mem;
use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_UNION_IN_NESTED_NS: u8 = 0;
@@ -43,8 +36,8 @@ impl UnionInNestedNS {
}
}
}
impl core::fmt::Debug for UnionInNestedNS {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
impl ::core::fmt::Debug for UnionInNestedNS {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
@@ -52,24 +45,24 @@ impl core::fmt::Debug for UnionInNestedNS {
}
}
}
impl<'a> flatbuffers::Follow<'a> for UnionInNestedNS {
impl<'a> ::flatbuffers::Follow<'a> for UnionInNestedNS {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { flatbuffers::read_scalar_at::<u8>(buf, loc) };
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
Self(b)
}
}
impl flatbuffers::Push for UnionInNestedNS {
impl ::flatbuffers::Push for UnionInNestedNS {
type Output = UnionInNestedNS;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { flatbuffers::emplace_scalar::<u8>(dst, self.0); }
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
}
}
impl flatbuffers::EndianScalar for UnionInNestedNS {
impl ::flatbuffers::EndianScalar for UnionInNestedNS {
type Scalar = u8;
#[inline]
fn to_little_endian(self) -> u8 {
@@ -83,17 +76,16 @@ impl flatbuffers::EndianScalar for UnionInNestedNS {
}
}
impl<'a> flatbuffers::Verifiable for UnionInNestedNS {
impl<'a> ::flatbuffers::Verifiable for UnionInNestedNS {
#[inline]
fn run_verifier(
v: &mut flatbuffers::Verifier, pos: usize
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
use self::flatbuffers::Verifiable;
v: &mut ::flatbuffers::Verifier, pos: usize
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
u8::run_verifier(v, pos)
}
}
impl flatbuffers::SimpleToVerifyInSlice for UnionInNestedNS {}
impl ::flatbuffers::SimpleToVerifyInSlice for UnionInNestedNS {}
pub struct UnionInNestedNSUnionTableOffset {}
#[allow(clippy::upper_case_acronyms)]
@@ -101,7 +93,7 @@ pub struct UnionInNestedNSUnionTableOffset {}
#[derive(Debug, Clone, PartialEq)]
pub enum UnionInNestedNST {
NONE,
TableInNestedNS(Box<TableInNestedNST>),
TableInNestedNS(alloc::boxed::Box<TableInNestedNST>),
}
impl Default for UnionInNestedNST {
fn default() -> Self {
@@ -115,16 +107,16 @@ impl UnionInNestedNST {
Self::TableInNestedNS(_) => UnionInNestedNS::TableInNestedNS,
}
}
pub fn pack<'b, A: flatbuffers::Allocator + 'b>(&self, fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>) -> Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>> {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(&self, fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>) -> Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>> {
match self {
Self::NONE => None,
Self::TableInNestedNS(v) => Some(v.pack(fbb).as_union_value()),
}
}
/// If the union variant matches, return the owned TableInNestedNST, setting the union to NONE.
pub fn take_table_in_nested_ns(&mut self) -> Option<Box<TableInNestedNST>> {
pub fn take_table_in_nested_ns(&mut self) -> Option<alloc::boxed::Box<TableInNestedNST>> {
if let Self::TableInNestedNS(_) = self {
let v = core::mem::replace(self, Self::NONE);
let v = ::core::mem::replace(self, Self::NONE);
if let Self::TableInNestedNS(w) = v {
Some(w)
} else {