defmt needs to generate symbol names that are unique per macro invocation, even when the macro arguments are identical. We don't want to generate a random number to keep builds reproducible, so what we do currently is:
// We want a deterministic, but unique-per-macro-invocation identifier. For that we
// hash the call site `Span`'s debug representation, which contains a counter that
// should disambiguate macro invocations within a crate.
let s = format!("{:?}", Span::call_site());
let mut hasher = DefaultHasher::new();
s.hash(&mut hasher);
hasher.finish()
This relies on the debug representation of Span, which is probably not the best idea.
defmt needs to generate symbol names that are unique per macro invocation, even when the macro arguments are identical. We don't want to generate a random number to keep builds reproducible, so what we do currently is:
This relies on the debug representation of
Span
, which is probably not the best idea.Until access to line and column of the span is possible in stable Rust (cc https://github.com/rust-lang/rust/issues/54725), we don't really have a good way of fixing this.