Skip to content

Commit

Permalink
Merge #692
Browse files Browse the repository at this point in the history
692: Wrap const fn in const item to ensure compile-time-evaluation. r=jonas-schievink a=Urhengulas

This reduces the size of the resulting binary in debug builds.

Fixes #691.

Co-authored-by: Urhengulas <johann.hemmann@code.berlin>
Co-authored-by: Johann Hemmann <johann.hemmann@code.berlin>
  • Loading branch information
bors[bot] and Urhengulas authored Aug 16, 2022
2 parents 8cf6efe + ceb875e commit a8b0fdf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- [#692]: Wrap const fn in const item to ensure compile-time-evaluation.
- [#690]: Satisfy clippy
- [#688]: Release `defmt-decoder 0.3.3`
- [#687]: `CI`: Re-enable `qemu-snapshot (nightly)` tests
Expand All @@ -18,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- [#679]: Add changelog enforcer
- [#678]: Satisfy clippy

[#692]: https://github.com/knurling-rs/defmt/pull/692
[#690]: https://github.com/knurling-rs/defmt/pull/690
[#688]: https://github.com/knurling-rs/defmt/pull/688
[#687]: https://github.com/knurling-rs/defmt/pull/687
Expand Down
16 changes: 9 additions & 7 deletions macros/src/function_like/log/env_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,15 @@ impl EnvFilter {
.collect::<Vec<_>>();

Some(quote!({
const fn check() -> bool {
let module_path = module_path!().as_bytes();
#(#checks)*
false
}

check()
const CHECK: bool = {
const fn check() -> bool {
let module_path = module_path!().as_bytes();
#(#checks)*
false
}
check()
};
CHECK
}))
}

Expand Down

0 comments on commit a8b0fdf

Please sign in to comment.