BROKEN: Attempt to support #[track_caller] #354
Draft
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.
Attempt to fix issue #342
Due to the need to create
&'static RecordStaticat compile time, this is much more difficult than adding support in the log crate.I tried various combination of inline const and const declaration.
In each case, the
track_caller::track_callertest failed to respect the#[track_caller]attribute.It turns out that there is a bizarre interaction that meansLocation::callerdoes not respect#[track_caller]in a const-eval context.EDIT: This is not a "bizzare interaction", it is a fundamental limitation of const-eval.
See here for a demo: https://gist.github.com/Techcable/a80e3a4c4d928a2038dc45bd6d91f9e4
You can also run this in the playground.
A workaround would be adding a
&'static Locationto theslog::Recordstruct, but this would add another pointer to the record and possibly break backwards compatibility.