Skip to content

Commit 5f453ef

Browse files
authored
Removes 'size' and 'alignment' as Rust keywords (#8139)
* Adds fields for possibly reserved words to rust_namer_test * Removes size and alignment as rust reserved words
1 parent 49061f8 commit 5f453ef

23 files changed

Lines changed: 268 additions & 25 deletions

File tree

samples/rust_generated/my_game/sample/vec_3_generated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'b> flatbuffers::Push for Vec3 {
4747
type Output = Vec3;
4848
#[inline]
4949
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
50-
let src = ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, Self::size());
50+
let src = ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, <Self as flatbuffers::Push>::size());
5151
dst.copy_from_slice(src);
5252
}
5353
#[inline]

src/idl_gen_rust.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ static std::set<std::string> RustKeywords() {
131131
// Terms that we use ourselves
132132
"follow",
133133
"push",
134-
"size",
135-
"alignment",
136134
"to_little_endian",
137135
"from_little_endian",
138136
"ENUM_MAX",
@@ -2700,7 +2698,7 @@ class RustGenerator : public BaseGenerator {
27002698
code_ += " unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {";
27012699
code_ +=
27022700
" let src = ::core::slice::from_raw_parts(self as *const "
2703-
"{{STRUCT_TY}} as *const u8, Self::size());";
2701+
"{{STRUCT_TY}} as *const u8, <Self as flatbuffers::Push>::size());";
27042702
code_ += " dst.copy_from_slice(src);";
27052703
code_ += " }";
27062704
code_ += " #[inline]";

tests/arrays_test/my_game/example/array_struct_generated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl<'b> flatbuffers::Push for ArrayStruct {
5050
type Output = ArrayStruct;
5151
#[inline]
5252
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
53-
let src = ::core::slice::from_raw_parts(self as *const ArrayStruct as *const u8, Self::size());
53+
let src = ::core::slice::from_raw_parts(self as *const ArrayStruct as *const u8, <Self as flatbuffers::Push>::size());
5454
dst.copy_from_slice(src);
5555
}
5656
#[inline]

tests/arrays_test/my_game/example/nested_struct_generated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<'b> flatbuffers::Push for NestedStruct {
4848
type Output = NestedStruct;
4949
#[inline]
5050
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
51-
let src = ::core::slice::from_raw_parts(self as *const NestedStruct as *const u8, Self::size());
51+
let src = ::core::slice::from_raw_parts(self as *const NestedStruct as *const u8, <Self as flatbuffers::Push>::size());
5252
dst.copy_from_slice(src);
5353
}
5454
#[inline]

tests/include_test1/my_game/other_name_space/unused_generated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<'b> flatbuffers::Push for Unused {
4545
type Output = Unused;
4646
#[inline]
4747
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
48-
let src = ::core::slice::from_raw_parts(self as *const Unused as *const u8, Self::size());
48+
let src = ::core::slice::from_raw_parts(self as *const Unused as *const u8, <Self as flatbuffers::Push>::size());
4949
dst.copy_from_slice(src);
5050
}
5151
#[inline]

tests/include_test2/my_game/other_name_space/unused_generated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<'b> flatbuffers::Push for Unused {
4545
type Output = Unused;
4646
#[inline]
4747
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
48-
let src = ::core::slice::from_raw_parts(self as *const Unused as *const u8, Self::size());
48+
let src = ::core::slice::from_raw_parts(self as *const Unused as *const u8, <Self as flatbuffers::Push>::size());
4949
dst.copy_from_slice(src);
5050
}
5151
#[inline]

tests/monster_test/my_game/example/ability_generated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<'b> flatbuffers::Push for Ability {
4646
type Output = Ability;
4747
#[inline]
4848
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
49-
let src = ::core::slice::from_raw_parts(self as *const Ability as *const u8, Self::size());
49+
let src = ::core::slice::from_raw_parts(self as *const Ability as *const u8, <Self as flatbuffers::Push>::size());
5050
dst.copy_from_slice(src);
5151
}
5252
#[inline]

tests/monster_test/my_game/example/struct_of_structs_generated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'b> flatbuffers::Push for StructOfStructs {
4747
type Output = StructOfStructs;
4848
#[inline]
4949
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
50-
let src = ::core::slice::from_raw_parts(self as *const StructOfStructs as *const u8, Self::size());
50+
let src = ::core::slice::from_raw_parts(self as *const StructOfStructs as *const u8, <Self as flatbuffers::Push>::size());
5151
dst.copy_from_slice(src);
5252
}
5353
#[inline]

tests/monster_test/my_game/example/struct_of_structs_of_structs_generated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<'b> flatbuffers::Push for StructOfStructsOfStructs {
4545
type Output = StructOfStructsOfStructs;
4646
#[inline]
4747
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
48-
let src = ::core::slice::from_raw_parts(self as *const StructOfStructsOfStructs as *const u8, Self::size());
48+
let src = ::core::slice::from_raw_parts(self as *const StructOfStructsOfStructs as *const u8, <Self as flatbuffers::Push>::size());
4949
dst.copy_from_slice(src);
5050
}
5151
#[inline]

tests/monster_test/my_game/example/test_generated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<'b> flatbuffers::Push for Test {
4646
type Output = Test;
4747
#[inline]
4848
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
49-
let src = ::core::slice::from_raw_parts(self as *const Test as *const u8, Self::size());
49+
let src = ::core::slice::from_raw_parts(self as *const Test as *const u8, <Self as flatbuffers::Push>::size());
5050
dst.copy_from_slice(src);
5151
}
5252
#[inline]

0 commit comments

Comments
 (0)