-
Notifications
You must be signed in to change notification settings - Fork 900
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
Refactor fmt modules into a single shared embassy_fmt crate #190
Conversation
226405f
to
3fb6056
Compare
I realized how to do this without namespaced-features, so i've removed it. (in hindsight it was pretty obvious) |
dbd7641
to
0b8e456
Compare
Sorry for taking so long to get back to you on this 😓 This fmt stuff is a very very hairy topic. I do agree the current solution is very suboptimal, however it's been changed many times already in the past and it seems all solutions that we find have some downside :( The
I think due to the last point we're stuck with copypasting a For example, to avoid "unused import" warnings depending on log/defmt features maybe all macros should be |
thanks for the feedback! |
advantages:
#[macro_use] extern crate embassy_fmt
ensure that we always use the defmt macros over the space expensive core macros.use crate::fmt::{unreachable, *};
which will importunreachable
and give a compile error if any formatting macros are used but not manually imported. But I was accidentally deleting these because of the unused warnings and I didnt realize they create a helpful compiler error instead of using a core format macro.pub use
d macros are imported into the fmt module while the new macro_rules macros have a global scope. This means the macros are accessible at different paths depending on if the defmt feature is enabled or not. There are two ways to resolve this issue:#![feature(pub_macro_rules)]
rust-lang/rust#78855disadvantages:
We could potentially provide embassy_fmt as a wrapper over defmt/log for end users but for now its just considered an implementation detail.
I havent changed stm32 to use it yet, I plan to do that in a follow up PR which will also add a .cargo/config and fix the warnings for stm32.