Make debugging in release build a compiler error #43
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.
This commit adds macros
ddbg
anddprintln
, which are defined in debug builds, but not in release builds. So, if they appear in code they will result in a compile time error when doing a release build. These are only added to theoq3_semantics
crate. They would have to be duplicated to use them in other crates. Or perhaps moved to the lexer crate, which all others depend on, directly or indirectly.Using these requires also
#[cfg(debug_assertions)]
when importing them.I have seen an implementation of something similar that includes a definition of the macros for release builds. This does not then require #[cfg(debug_assertions)] on import. We could do something similar, by making
ddbg
expand to something that fails to compile, say references an undefined variable. But that would not be very robust.There is a probably a standalone, registered, crate to do things like this. But I was unable to find such a crate. Nor did I find online any reference to the basic problem this is meant to solve.