-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Safe mode for collisions #2279
Comments
Could you please provide a minimal reproducible sample? Without example, I guess maybe you have this same name somewhere else. Usually mirroring should not trigger this warning.
Feel free to PR to add this! Currently I choose to make it INFO message (instead of a hard error), because it is mostly harmless (especially if you do not use it), and even if it does cause problem, picking the wrong type seems to cause the generated code have wrong type, then Rust compiler will stop you from compiling. |
Sounds good, I will report back if I can figure out what exactly is causing it. |
With a bit more looking, and your explanation comment on another issue, I think this specific issue is actually related to the third party crates feature, i.e. that the whole third-party crate gets scanned, not just the module listed in rust_input. So my theory is: api.rs has a pub use foo::bar::baz and mirrors it. I think the broader point is it's hard to have both convenient, zero-configuration scanning of Rust imports, and also fine-grained control over what Dart code is being generated and how. To do it, FRB would need to canonicalize all the Rust types in the system with the same logic as the Rust itself, and project that into Dart. As for a safe mode, it is reassuring to know we would get a compile error if there is a bug. The error doesn't have to come from FRB, I just want to avoid doing anything that could hide bugs. |
Yes, and that would be quite nontrivial, since Rust resolution logic is quite complex... (That's partially why this feature is marked as experimental)
Yes I agree (see my comments above) |
I thought about it a bit more, and seems that if we create a safe mode, then it is not very useful, because we cannot easily remove that hint for types that are scanned but not used. |
Makes sense. Seems hard to do much better without being able to resolve Rust types the same way as Rust itself. |
Totally agree... |
Is your feature request related to a problem? Please describe.
I see a scary warning:
I am using the object. In my flutter crate I
pub use
it, and then create afrb(mirror)
on it. I'm not sure why this type has this error but some of my other mirrored types don't. With this info message, I am wondering if I have a bug that can bite me later.Describe the solution you'd like
I want to run FRB in a very rust-y 'safe'/'strict' mode where if it could do the wrong thing, that's an error, with info on how to fix.
Describe alternatives you've considered
N/A
The text was updated successfully, but these errors were encountered: