Align derive placeholder formatting with TemplateFormatter variants#62
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".
| fn format_with_alternate(expr: TokenStream, specifier: char) -> TokenStream { | ||
| let format_string = format!("{{:#{}}}", specifier); | ||
| quote! { | ||
| ::core::write!(f, #format_string, #expr)?; | ||
| } |
There was a problem hiding this comment.
[P0] Generate string literal using non-tokenizable String
The new helper format_with_alternate constructs a String with format! and then interpolates it directly into quote! (::core::write!(f, #format_string, #expr)?;). quote! requires the interpolated value to implement ToTokens, which String does not, so the proc-macro crate will fail to compile as soon as this arm is exercised. The previous implementation used a literal format string and compiled successfully. Convert the computed string into a token type (e.g. syn::LitStr::new(&format_string, Span::call_site())) before interpolation.
Useful? React with 👍 / 👎.
Summary
TemplateFormattervariant and invoke the corresponding::core::fmttrait or alternate formatting helperTesting
https://chatgpt.com/codex/tasks/task_e_68cce3e90278832b85aa0850144c3314