Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion goldens/rust/basic_generated.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// automatically generated by the FlatBuffers compiler, do not modify
// @generated
extern crate alloc;

extern crate alloc;

#[allow(unused_imports, dead_code)]
pub mod flatbuffers {

extern crate alloc;
#[allow(unused_imports, dead_code)]
pub mod goldens {

extern crate alloc;

pub enum GalaxyOffset {}
#[derive(Copy, Clone, PartialEq)]
Expand Down
17 changes: 17 additions & 0 deletions scripts/generate_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ def glob(path, pattern):
"--gen-name-strings",
"--rust-module-root-file",
]
RUST_STANDALONE_OPTS = BASE_OPTS + [
"--rust",
"--gen-all",
"--gen-name-strings",
]
RUST_SERIALIZE_OPTS = BASE_OPTS + [
"--rust",
"--gen-all",
Expand Down Expand Up @@ -288,13 +293,25 @@ def glob(path, pattern):
schema="include_test/include_test1.fbs",
)

flatc(
RUST_STANDALONE_OPTS,
include="include_test",
schema="include_test/include_test1.fbs",
)

flatc(
RUST_OPTS,
prefix="include_test2",
include="include_test",
schema="include_test/sub/include_test2.fbs",
)

flatc(
RUST_STANDALONE_OPTS,
include="include_test",
schema="include_test/sub/include_test2.fbs",
)

flatc(
BINARY_OPTS + ["--bfbs-filenames", str(tests_path)],
include="include_test",
Expand Down
2 changes: 1 addition & 1 deletion src/idl_gen_rust.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ class RustGenerator : public BaseGenerator {
code_.Clear();
code_ += "// " + std::string(FlatBuffersGeneratedWarning());
code_ += "// @generated";
code_ += "extern crate alloc;";

assert(!cur_name_space_);

Expand Down Expand Up @@ -3005,6 +3004,7 @@ class RustGenerator : public BaseGenerator {
"use self::serde::ser::{Serialize, Serializer, SerializeStruct};";
code_ += "";
}
code_ += "extern crate alloc;";
}

// Set up the correct namespace. This opens a namespace if the current
Expand Down
Loading
Loading