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
This commit is contained in:
Cameron Mulhern
2024-11-12 00:13:02 -05:00
committed by GitHub
parent 49061f8c7c
commit 5f453ef738
23 changed files with 268 additions and 25 deletions

View File

@@ -131,8 +131,6 @@ static std::set<std::string> RustKeywords() {
// Terms that we use ourselves
"follow",
"push",
"size",
"alignment",
"to_little_endian",
"from_little_endian",
"ENUM_MAX",
@@ -2700,7 +2698,7 @@ class RustGenerator : public BaseGenerator {
code_ += " unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {";
code_ +=
" let src = ::core::slice::from_raw_parts(self as *const "
"{{STRUCT_TY}} as *const u8, Self::size());";
"{{STRUCT_TY}} as *const u8, <Self as flatbuffers::Push>::size());";
code_ += " dst.copy_from_slice(src);";
code_ += " }";
code_ += " #[inline]";