Closed tmpfs closed 1 year ago
Weird... Could you please make a (more) minimal reproducible sample, so the problem can be spotted more easily?
could you please modify it manually (as a hack) e.g.
impl Wire2Api<GeneratorType> for i32 { fn wire2api(self) -> GeneratorType { println!("hack! {}", self); <------ match self { 0 => GeneratorType::LettersNumbers, 1 => GeneratorType::Numbers, 2 => GeneratorType::Random, _ => unreachable!("Invalid variant for GeneratorType: {}", self), } } }
and see the value
This just prints 16
as expected.
Weird... Could you please make a (more) minimal reproducible sample, so the problem can be spotted more easily?
Sure, I will try, it will take a while though as it is quite time consuming to set all this up for a new project.
I will try to debug the generated bindings a bit first on Windows to see if I can determine the cause of the problem.
This just prints 16 as expected.
Yes I realized that later
FYI, this has existed for a while. I was using 1.46 and upgraded to 1.57 so see if a fix was present.
Just upgraded ffigen
from 6.1.2
to 7.2.4
and this part of the diff seems interesting:
class wire_PasswordGenerator extends ffi.Struct {
- @uintptr_t()
+ @ffi.UintPtr()
external int count;
@ffi.Int32()
external int generator;
- @uintptr_t()
+ @ffi.UintPtr()
external int length;
}
Just ran it on Windows and the problem has disappeared. What luck! 🥳
Happy to hear that!
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.
Describe the bug
On Windows I am hitting an
unreachable!()
on an enum invariant in the generated rust bindings.The error message in the unreachable is this:
On MacOS, iOS and Android the code works as expected.
The generated Rust code that throws the error is:
The type definitions for the relevant types are:
The binding function I am calling looks like this:
And the dart code that calls out looks like this:
The
Wire2Api
implementation seems fine:The very interesting thing is that the default value for
length
(_amount
in the dart code) is 16 which appears in the invariant error message.So it appears that only on Windows fields are getting mixed up, any ideas?
Codegen logs with
RUST_LOG=debug
environment variableTo Reproduce
No response
Expected behavior
No response
Generated binding code
No response
OS
Windows
Version of
flutter_rust_bridge_codegen
1.57
Flutter info
No response
Version of
clang++
No response
Version of
ffigen
6.1.2
Additional context
No response