Add extended template formatter support#60
Conversation
There was a problem hiding this comment.
Codex Review: Here are some suggestions.
Reply with @codex fix comments to fix any unresolved comments.
About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".
| TemplateFormatter::Pointer { | ||
| alternate | ||
| } => { | ||
| if alternate { | ||
| quote! { write!(f, "{:#p}", #expr)?; } | ||
| } else if pointer_value { | ||
| quote! {{ | ||
| let value = #expr; | ||
| core::fmt::Pointer::fmt(&value, f)?; | ||
| }} | ||
| } else { | ||
| quote! { core::fmt::Pointer::fmt(#expr, f)?; } |
There was a problem hiding this comment.
[P1] Pointer formatter prints field addresses instead of pointer values
The pointer branch in format_placeholder still hands core::fmt::Pointer a reference to the placeholder expression (&value) even when pointer_value is true. For raw pointers, immutable references, NonNull, or {self:p}, this means the generated Display impl prints the address of the local/field that stores the pointer instead of the pointer value itself—{ptr:p} formats like format!("{:p}", &ptr) rather than format!("{:p}", ptr). As a result, pointer placeholders yield stack/field addresses rather than the intended target pointer, diverging from Rust’s built‑in pointer formatting. The branch should format the pointer value directly without introducing another &.
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68ccd3dbb7d0832b87ff220e11a9bf8e