Fix build compatibility with shadowed defmt macros#109
Open
WillaWillNot wants to merge 1 commit into
Open
Conversation
… inside proc macros are done with the fully qualified core library names (affects assert!, panic!, quote!, todo!, unreachable!, and write!). Add test that compilation with both bilge macro usage and defmt #[macro_use] succeeds. Fix expected stderr strings in failing examples.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Despite deprecation, it remains common practice to use defmt with
#[macro_use]enabled in embedded projects, to save code size by shadowing core library printing functions. (It ensures that dependencies don't bring in anycore::fmtfunctions via their own use of macros likepanic!().)It's currently impossible to mix that usage of defmt with bilge in the same crate, because several of bilge's proc macros utilize macros that might be shadowed by defmt without fully qualified names. This change adds qualified names to all of those uses, so that bilge can coexist with shadowed printing macros. Specifically, the macros used that needed qualified names were
assert!,panic!,quote!,todo!,unreachable!, andwrite!.Proc macros, if they ever interact with stdout, are meant to interact with the compiling host's stdout, not the target runtime stdout. So fully qualifying print macros to use the core library version is correct.
This change doesn't add actual defmt::Format support, that's a much larger scope. It's just meant to allow the crates to coexist. Defmt is added exclusively as a dev-dependency for the
defmt-compatibilitytest.The error produced when trying to build a crate with both bilge usage and shadowed defmt macros before this change is: