Skip to content

Conversation

@sabify
Copy link

@sabify sabify commented Jun 2, 2025

This PR fixes the Rust code generation to comply with Rust edition 2024 that requires indicating unsafe operations inside unsafe functions.

For reference: https://doc.rust-lang.org/nightly/edition-guide/rust-2024/unsafe-op-in-unsafe-fn.html

@github-actions github-actions bot added c++ codegen Involving generating code from schema rust labels Jun 2, 2025
@abalmos
Copy link

abalmos commented Jul 7, 2025

This would be nice to have. Can I help move it forward somehow?

@aleb
Copy link
Contributor

aleb commented Jul 10, 2025

The PR is incomplete, it only handles the Table::new call.
Some others that need to be fixed similarly:

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

Maybe you can find a way to compile each of the the generated samples, then you will notice all of these.

@aleb
Copy link
Contributor

aleb commented Jul 11, 2025

I needed this, so I made #8638

@fliiiix
Copy link
Contributor

fliiiix commented Aug 1, 2025

I guess this can be closed as #8638 is merged

@sabify sabify closed this Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ codegen Involving generating code from schema rust

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants